package com.smartleanx.module.hrm.service.salary;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.smartleanx.framework.common.pojo.CommonResult;
import com.smartleanx.framework.datapermission.core.annotation.DataPermission;
import com.smartleanx.framework.datapermission.core.util.DataPermissionUtils;
import com.smartleanx.framework.security.core.util.SecurityFrameworkUtils;
import com.smartleanx.module.hrm.dal.dataobject.dingDing.*;
import com.smartleanx.module.hrm.dal.dataobject.employee.EmployeeDO;
import com.smartleanx.module.hrm.dal.dataobject.employee.EmployeeSeparationRecordDO;
import com.smartleanx.module.hrm.dal.dataobject.programme.HrmProgrammeEmployeeRecord;
import com.smartleanx.module.hrm.dal.dataobject.salary.*;
import com.smartleanx.module.hrm.dal.mysql.dingDing.*;
import com.smartleanx.module.hrm.dal.mysql.employee.EmployeeMapper;
import com.smartleanx.module.hrm.dal.mysql.employee.EmployeeSeparationRecordMapper;
import com.smartleanx.module.hrm.dal.mysql.programme.HrmProgrammeEmployeeRecordMapper;
import com.smartleanx.module.hrm.dal.mysql.salary.*;
import com.smartleanx.module.hrm.service.examine.util.DateUtil;
import com.smartleanx.module.hrm.service.examine.util.exception.ResultException;
import com.smartleanx.module.hrm.service.programme.HrmProgrammeService;
import com.smartleanx.module.system.api.dept.DeptApi;
import com.smartleanx.module.system.api.dept.PostApi;
import com.smartleanx.module.system.api.dept.PostLevelApi;
import com.smartleanx.module.system.api.dept.dto.DeptRespDTO;
import com.smartleanx.module.system.api.dept.dto.PostLevelRespDTO;
import com.smartleanx.module.system.api.dept.dto.PostRespDTO;
import com.smartleanx.module.system.api.dict.DictDataApi;
import com.smartleanx.module.system.api.dict.dto.DictDataRespDTO;
import com.smartleanx.module.system.api.user.AdminUserApi;
import com.smartleanx.module.system.api.user.dto.AdminUserRespDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author mybatis-plus
 * @since 2025-01-10
 */
@Service
//@DataPermission(enable = false)
public class HrmSalaryRecordServiceImpl implements HrmSalaryRecordService {
    @Autowired
    private HrmSalaryFixedTableMapper hrmSalaryFixedTableMapper;
    @Autowired
    private HrmSalaryRecordMapper hrmSalaryRecordMapper;
    @Autowired
    private HrmSalaryFixedMapper hrmSalaryFixedMapper;
    @Autowired
    private HrmSalaryTableConfigMapper hrmSalaryTableConfigMapper;
    @Autowired
    private HrmSalaryPlanMapper hrmSalaryPlanMapper;
    @Autowired
    private HrmSalaryPlanEmployeeMapper hrmSalaryPlanEmployeeMapper;
    @Autowired
    private HrmSalarySettingMapper hrmSalarySettingMapper;
    @Autowired
    private HrmSalaryStandardMapper hrmSalaryStandardMapper;

    @Autowired
    private HrmSalaryTaxationRuleTenantMapper hrmSalaryTaxationRuleTenantMapper;
    @Autowired
    private HrmSalaryTemplateInfoMapper hrmSalaryTemplateInfoMapper;
    @Autowired
    private HrmSalaryTemplateMapper hrmSalaryTemplateMapper;
    @Autowired
    private HrmProgrammeEmployeeRecordMapper hrmProgrammeEmployeeRecordMapper;
    @Autowired
    private PostApi postApi;
    @Autowired
    private DeptApi deptApi;
    @Autowired
    private EmployeeMapper employeeMapper;
    @Autowired
    private EmployeeSeparationRecordMapper employeeSeparationRecordMapper;
    @Autowired
    private HrmSalaryTableConfigTenantEmployeeMapper hrmSalaryTableConfigTenantEmployeeMapper;
    @Autowired
    private HrmSalaryRecordEmployeeMapper hrmSalaryRecordEmployeeMapper;
    @Autowired
    private HrmSalaryRecordEmployeeTableMapper hrmSalaryRecordEmployeeTableMapper;
    @Autowired
    private HrmSalaryTableConfigTenantMapper hrmSalaryTableConfigTenantMapper;
    @Autowired
    private DingAttendanceRecordMapper dingAttendanceRecordMapper;
    @Autowired
    private DingColumnValueMapper dingColumnValueMapper;
    @Autowired
    private PostLevelApi postLevelApi;
    @Autowired
    private DictDataApi dictDataApi;
    @Autowired
    private DingColumnMapper dingColumnMapper;
    @Autowired
    private DingUserMapper dingUserMapper;
    @Autowired
    private DingAttendanceTeamMapper dingAttendanceTeamMapper;
    @Autowired
    private DingFalseDiligenceMapper dingFalseDiligenceMapper;
    @Autowired
    private DingAttendanceClassesMapper dingAttendanceClassesMapper;

    @Autowired
    private AdminUserApi adminUserApi;
    @Autowired
    private DingClassTeamMapper dingClassTeamMapper;

    @Autowired
    public HrmProgrammeService hrmProgrammeService;

    @Autowired
    private  SystemColumnTenantMapper systemColumnTenantMapper;

    @Autowired
    private SystemColumnValueMapper systemColumnValueMapper;

    @Autowired
    private SystemAttendanceTeamMapper systemAttendanceTeamMapper;
    @Autowired
    private SystemColumnMapper systemColumnMapper;
    @Autowired
    private DingAttendanceConfirmationMapper dingAttendanceConfirmationMapper;
    @Autowired
    private SystemFalseDiligenceMapper systemFalseDiligenceMapper;

    @Override
    public List<JSONObject> postLevelBySelect() {
        List<JSONObject> resultList = new ArrayList<>();
        CommonResult<List<PostLevelRespDTO>> allList = postLevelApi.getAllList();
        if (!ObjectUtils.isEmpty(allList.getData())) {
            for (PostLevelRespDTO datum : allList.getData()) {
                JSONObject obj = new JSONObject();
                obj.put("id", datum.getId());
                obj.put("value", datum.getName());
                resultList.add(obj);
            }
        }
        return resultList;
    }
    @Override
    public void generateSalaryRecord(Integer type, List<Integer> employeeId, String date) {
//        HrmSalarySetting salarySetting = hrmSalarySettingMapper.selectOne(new LambdaQueryWrapper<HrmSalarySetting>() {{
//            last("limit 1");
//        }});
//        if (type == 1) {
//            employeeId = employeeMapper.selectList().stream().map(e -> e.getId().intValue()).collect(Collectors.toList());
//        }
//        List<Integer> effectiveEmployeeId = new ArrayList<>();
//        Long loginId = SecurityFrameworkUtils.getLoginUserId();
//        EmployeeDO loginEmployee = employeeMapper.selectOne(new LambdaQueryWrapper<EmployeeDO>() {{
//            eq(EmployeeDO::getUserId, loginId);
//        }});
//        String createData = DateUtil.formatDateByYear(date);
//        Long l1 = hrmSalaryRecordMapper.selectCount(new LambdaQueryWrapper<HrmSalaryRecord>() {{
//            eq(HrmSalaryRecord::getEmployeeId, loginId);
//            eq(HrmSalaryRecord::getCreateTime, createData);
//        }});
//        if (l1 > 0) {
//            throw new ResultException(date + "工资数据已存在");
//        }
//
//        if (ObjectUtils.isEmpty(loginEmployee)) {
//            throw new ResultException("当前登录账号不可以创建生成薪资");
//        }
//
//        HrmSalaryRecord hrmSalaryRecord = new HrmSalaryRecord();
//        hrmSalaryRecord.setCreateTime(createData);
//        hrmSalaryRecord.setEmployeeId(loginEmployee.getId().intValue());
//        hrmSalaryRecord.setTime(DateUtil.currentDateFormat());
//        hrmSalaryRecordMapper.insert(hrmSalaryRecord);
//        //可生成薪资的员工
//        for (Integer e : employeeId) {
//            Integer finalE = e;
//            EmployeeDO employeeDO = employeeMapper.selectOne(new LambdaQueryWrapper<EmployeeDO>() {{
//                eq(EmployeeDO::getUserId, finalE);
//            }});
//            if (ObjectUtils.isEmpty(employeeDO)) {
//                continue;
//            }
//            e = employeeDO.getId().intValue();
//            HrmSalaryPlanEmployee salaryPlanEmployee = hrmSalaryPlanEmployeeMapper.selectOne(new LambdaQueryWrapper<HrmSalaryPlanEmployee>() {{
//                eq(HrmSalaryPlanEmployee::getEmployeeId, employeeDO.getUserId().intValue());
//            }});
//            if (!ObjectUtils.isEmpty(salaryPlanEmployee)) {
//                effectiveEmployeeId.add(e);
//            }
//        }
//        if (ObjectUtils.isEmpty(effectiveEmployeeId)) {
//            throw new ResultException("没有可生成薪资的员工");
//        }
//        for (Integer e : effectiveEmployeeId) {
//            BigDecimal kqKK = BigDecimal.ZERO;
//            BigDecimal accountSb = BigDecimal.ZERO;
//            BigDecimal grSb = BigDecimal.ZERO;
//            BigDecimal accountGjj = BigDecimal.ZERO;
//            BigDecimal grGjj = BigDecimal.ZERO;
//            BigDecimal yf = BigDecimal.ZERO;
//            BigDecimal sf = BigDecimal.ZERO;
//            Integer employeeStatus = -1;
//            BigDecimal sumSalary = BigDecimal.ZERO;
//            //部门岗位
//            EmployeeDO employeeDO = employeeMapper.selectById(e);
//            //薪资方案
//            HrmSalaryPlanEmployee salaryPlanEmployee = hrmSalaryPlanEmployeeMapper.selectOne(new LambdaQueryWrapper<HrmSalaryPlanEmployee>() {{
//                eq(HrmSalaryPlanEmployee::getEmployeeId, employeeDO.getUserId().intValue());
//            }});
//            //计税
//            HrmSalaryPlan hrmSalaryPlan = hrmSalaryPlanMapper.selectById(salaryPlanEmployee.getPlanId());
//            if (hrmSalaryPlan.getMonthlySalaryStandard() == 1) {
//                HrmSalaryFixed hrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//                    eq(HrmSalaryFixed::getEmployeeId, e);
////                le(HrmSalaryFixed::getDate, date+"-31 00:00:00");
//                    eq(HrmSalaryFixed::getIsEffect, 1);
//                    orderByDesc(HrmSalaryFixed::getDate);
//                    last("limit 1");
//                }});
//                if (ObjectUtils.isEmpty(hrmSalaryFixed)) {
//                    HrmSalaryRecordEmployee hrmSalaryRecordEmployee = new HrmSalaryRecordEmployee();
//                    hrmSalaryRecordEmployee.setRecordId(hrmSalaryRecord.getId());
////                    hrmSalaryRecordEmployee.setSalaryFixedId(hrmSalaryFixed.getId());
//                    hrmSalaryRecordEmployee.setEmployeeId(e);
//                    hrmSalaryRecordEmployee.setEmployeeName(employeeDO.getName());
//                    hrmSalaryRecordEmployee.setEmployeeNo(employeeDO.getEmployeeNo());
//                    hrmSalaryRecordEmployee.setDepartmentId(employeeDO.getDeptId().intValue());
//                    hrmSalaryRecordEmployee.setPostId(employeeDO.getPostId().intValue());
//                    hrmSalaryRecordEmployee.setCreateTime(DateUtil.currentDateFormat());
//                    hrmSalaryRecordEmployee.setCreateBy(loginEmployee.getId().intValue());
//                    hrmSalaryRecordEmployeeMapper.insert(hrmSalaryRecordEmployee);
//                    List<HrmSalaryTableConfigTenant> hrmSalaryTableConfigTenants = hrmSalaryTableConfigTenantMapper.selectList(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
//                        eq(HrmSalaryTableConfigTenant::getIsDisplayed, 1);
//                        ne(HrmSalaryTableConfigTenant::getPid, 0);
//                        orderByAsc(HrmSalaryTableConfigTenant::getTableOrder);
//                    }});
//                    for (int i = 0; i < hrmSalaryTableConfigTenants.size(); i++) {
//                        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryTableConfigTenants.get(i).getId());
//                        if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                            continue;
//                        }
//                        HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
//                        hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenants.get(i).getId());
//                        hrmSalaryRecordEmployeeTable.setValue(BigDecimal.ZERO);
//                        hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
//                        hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
//                    }
//                    continue;
//                }
//                HrmSalaryRecordEmployee hrmSalaryRecordEmployee = new HrmSalaryRecordEmployee();
//                hrmSalaryRecordEmployee.setRecordId(hrmSalaryRecord.getId());
//                hrmSalaryRecordEmployee.setSalaryFixedId(hrmSalaryFixed.getId());
//                hrmSalaryRecordEmployee.setEmployeeId(e);
//                hrmSalaryRecordEmployee.setEmployeeName(employeeDO.getName());
//                hrmSalaryRecordEmployee.setEmployeeNo(employeeDO.getEmployeeNo());
//                hrmSalaryRecordEmployee.setDepartmentId(employeeDO.getDeptId().intValue());
//                hrmSalaryRecordEmployee.setPostId(employeeDO.getPostId().intValue());
//                hrmSalaryRecordEmployee.setCreateTime(DateUtil.currentDateFormat());
//                hrmSalaryRecordEmployee.setCreateBy(loginEmployee.getId().intValue());
//                hrmSalaryRecordEmployeeMapper.insert(hrmSalaryRecordEmployee);
//                //设置的员工基本项工资
//                List<HrmSalaryFixedTable> hrmSalaryFixedTables = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                    eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed.getId());
//                }});
//                EmployeeSeparationRecordDO employeeSeparationRecordDO = employeeSeparationRecordMapper.selectOne(new LambdaQueryWrapper<EmployeeSeparationRecordDO>() {{
//                    eq(EmployeeSeparationRecordDO::getEmployeeId, employeeDO.getId());
//                    eq(EmployeeSeparationRecordDO::getDeleted, 0);
//                    eq(EmployeeSeparationRecordDO::getApproveResult, 2);
//
//                }});
//                if (employeeDO.getState() == 3 || (!ObjectUtils.isEmpty(employeeSeparationRecordDO) && employeeSeparationRecordDO.getOldEmployeeState() == 3)) {
//                    employeeStatus = 1;
//                } else {
//                    employeeStatus = 0;
//                }
//                List<HrmSalaryTableConfigTenant> hrmSalaryTableConfigTenants = hrmSalaryTableConfigTenantMapper.selectList(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
//                    eq(HrmSalaryTableConfigTenant::getIsDisplayed, 1);
//                    ne(HrmSalaryTableConfigTenant::getPid, 0);
//                    orderByAsc(HrmSalaryTableConfigTenant::getTableOrder);
//                }});
//                for (int i = 0; i < hrmSalaryTableConfigTenants.size(); i++) {
//                    HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryTableConfigTenants.get(i).getId());
//                    if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                        continue;
//                    }
//                    HrmSalaryFixedTable hrmSalaryFixedTable = hrmSalaryFixedTableMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                        eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed.getId());
//                        eq(HrmSalaryFixedTable::getTableId, hrmSalaryTableConfigTenant.getId());
//                    }});
//                    HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
//                    hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenants.get(i).getId());
//                    if (employeeStatus == 0 && !ObjectUtils.isEmpty(hrmSalaryFixedTable)) {
//                        hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeFrontAmount());
//                    } else if (employeeStatus == 1 && !ObjectUtils.isEmpty(hrmSalaryFixedTable)) {
//                        hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
//                    }
//                    hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
//                    hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
//                }
//                HrmProgrammeEmployeeRecord hrmProgrammeEmployeeRecord = hrmProgrammeEmployeeRecordMapper.selectOne(new LambdaQueryWrapper<HrmProgrammeEmployeeRecord>() {{
//                    eq(HrmProgrammeEmployeeRecord::getEmployeeId, e);
//                    if (salarySetting.getType() == 1) {
//                        LocalDate localDate = LocalDate.parse(date + "-01", DateTimeFormatter.ISO_LOCAL_DATE);
//                        LocalDate previousMonth = localDate.minusMonths(1);
//                        String previousMonthStr = previousMonth.format(DateTimeFormatter.ofPattern("yyyy-MM"));
//                        eq(HrmProgrammeEmployeeRecord::getProgrammeStartTime, previousMonthStr);
//                    } else if (salarySetting.getType() == 2) {
//                        eq(HrmProgrammeEmployeeRecord::getProgrammeStartTime, date);
//                    }
//                    last("limit 1");
//                }});
//                if (!ObjectUtils.isEmpty(hrmProgrammeEmployeeRecord)) {
//                    accountGjj = hrmProgrammeEmployeeRecord.getAccumulationAmount();
//                    grGjj = hrmProgrammeEmployeeRecord.getEmployeeAccumulationAmount();
//                    accountSb = hrmProgrammeEmployeeRecord.getAccumulationAmount();
//                    grSb = hrmProgrammeEmployeeRecord.getEmployeeAccumulationAmount();
//                }
//                LocalDateTime regularizationTime = employeeDO.getRegularizationTime();
//                if (ObjectUtils.isEmpty(regularizationTime)) {
//                    HrmSalaryFixed hrmSalaryFixed1 = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//                        eq(HrmSalaryFixed::getEmployeeId, e);
//                        eq(HrmSalaryFixed::getIsEffect, 1);
//                        orderByDesc(HrmSalaryFixed::getDate);
//                        last("limit 1");
//                    }});
//
//                    if (!ObjectUtils.isEmpty(hrmSalaryFixed1)) {
//                        List<HrmSalaryFixedTable> hrmSalaryFixedTables1 = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                            eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed1.getId());
//                        }});
//                        for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTables1) {
//                            HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTables.get(0).getTableId());
//                            if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                                continue;
//                            }
//                            sf = sf.add(hrmSalaryFixedTable.getBecomeFrontAmount());
//                            yf = yf.add(hrmSalaryFixedTable.getBecomeFrontAmount());
//                        }
//                    }
//                } else {
//                    Long zzTime = employeeDO.getRegularizationTime().toEpochSecond(java.time.ZoneOffset.UTC) * 1000;
//                    long dateStart = DateUtil.strYearMonth(date + "-01");
//                    long dateEnd = DateUtil.strYearMonth(date + "-31");
//                    //看是不是生成工资月转正的
//                    if (zzTime >= dateStart && zzTime <= dateEnd) {
//                        if (hrmSalaryPlan.getSalaryAdjustmentRules() == 1) {
//                            BigDecimal syqZgz = BigDecimal.ZERO;
//                            BigDecimal zzhZgz = BigDecimal.ZERO;
//                            HrmSalaryFixed hrmSalaryFixed1 = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//                                eq(HrmSalaryFixed::getEmployeeId, e);
//                                le(HrmSalaryFixed::getDate, DateUtil.longToString(zzTime));
//                                eq(HrmSalaryFixed::getIsEffect, 1);
//                                last("limit 1");
//                            }});
//
//                            HrmSalaryFixed finalHrmSalaryFixed = hrmSalaryFixed1;
//                            List<HrmSalaryFixedTable> hrmSalaryFixedTables1 = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                                eq(HrmSalaryFixedTable::getFixedId, finalHrmSalaryFixed.getId());
//                            }});
//                            for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTables1) {
//                                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
//                                if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                                    syqZgz = syqZgz.add(BigDecimal.ZERO);
//                                } else {
//                                    syqZgz = syqZgz.add(hrmSalaryFixedTable.getBecomeFrontAmount());
//                                }
//                            }
//                            sf = sf.add(syqZgz);
//                            yf = yf.add(syqZgz);
//                            hrmSalaryFixed1 = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//                                eq(HrmSalaryFixed::getEmployeeId, e);
//                                orderByDesc(HrmSalaryFixed::getDate);
//                                eq(HrmSalaryFixed::getIsEffect, 1);
//                                last("limit 1");
//                            }});
//                            hrmSalaryFixedTables1 = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                                eq(HrmSalaryFixedTable::getFixedId, finalHrmSalaryFixed.getId());
//                            }});
//                            for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTables1) {
//                                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
//                                if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                                    zzhZgz = zzhZgz.add(BigDecimal.ZERO);
//                                } else {
//                                    zzhZgz = zzhZgz.add(hrmSalaryFixedTable.getBecomeAfterAmount());
//                                }
//                            }
//                            sf = sf.add(zzhZgz);
//                            yf = yf.add(zzhZgz);
//                        } else if (hrmSalaryPlan.getSalaryAdjustmentRules() == 2) {
//                            BigDecimal zzhZAmount = BigDecimal.ZERO;
//                            HrmSalaryFixed hrmSalaryFixed1 = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//                                eq(HrmSalaryFixed::getEmployeeId, e);
//                                eq(HrmSalaryFixed::getIsEffect, 1);
//                                orderByDesc(HrmSalaryFixed::getDate);
//                                last("limit 1");
//                            }});
//                            List<HrmSalaryFixedTable> hrmSalaryFixedTables1 = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                                eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed1.getId());
//                            }});
//                            for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTables1) {
//                                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
//                                if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                                    zzhZAmount = zzhZAmount.add(BigDecimal.ZERO);
//                                } else {
//                                    zzhZAmount = zzhZAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
//                                }
//
//                            }
//                            sf = sf.add(zzhZAmount);
//                            yf = yf.add(zzhZAmount);
//                        } else if (hrmSalaryPlan.getSalaryAdjustmentRules() == 3) {
//                            BigDecimal zgzAmount = BigDecimal.ZERO;
//                            Long l = DateUtil.strZLong(date + "-15");
//                            if (zzTime < l) {
//                                HrmSalaryFixed hrmSalaryFixed1 = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//                                    eq(HrmSalaryFixed::getEmployeeId, e);
////                                  le(HrmSalaryFixed::getDate, DateUtil.longToString(zzTime));
//                                    eq(HrmSalaryFixed::getIsEffect, 1);
//                                    orderByDesc(HrmSalaryFixed::getDate);
//                                    last("limit 1");
//                                }});
//                                List<HrmSalaryFixedTable> hrmSalaryFixedTables1 = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                                    eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed1.getId());
//                                }});
//                                for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTables1) {
//                                    HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
//                                    if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                                        zgzAmount = zgzAmount.add(BigDecimal.ZERO);
//                                    } else {
//                                        zgzAmount = zgzAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
//                                    }
//
//                                }
//                            } else {
//                                HrmSalaryFixed hrmSalaryFixed1 = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//                                    eq(HrmSalaryFixed::getEmployeeId, e);
//                                    le(HrmSalaryFixed::getDate, DateUtil.longToString(zzTime));
//                                    eq(HrmSalaryFixed::getIsEffect, 1);
//                                    orderByDesc(HrmSalaryFixed::getDate);
//                                    last("limit 1");
//                                }});
//                                if (ObjectUtils.isEmpty(hrmSalaryFixed1)) {
//                                    HrmSalaryFixed hrmSalaryFixed2 = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//                                        eq(HrmSalaryFixed::getEmployeeId, e);
////                                 le(HrmSalaryFixed::getDate, DateUtil.longToString(zzTime));
//                                        eq(HrmSalaryFixed::getIsEffect, 1);
//                                        orderByDesc(HrmSalaryFixed::getDate);
//                                        last("limit 1");
//                                    }});
//
//                                    List<HrmSalaryFixedTable> hrmSalaryFixedTables1 = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                                        eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed2.getId());
//                                    }});
//                                    for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTables1) {
//                                        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
//                                        if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                                            zgzAmount = zgzAmount.add(BigDecimal.ZERO);
//                                        } else {
//                                            zgzAmount = zgzAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
//                                        }
//
//                                    }
//                                } else {
//                                    List<HrmSalaryFixedTable> hrmSalaryFixedTables1 = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                                        eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed1.getId());
//                                    }});
//                                    for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTables1) {
//                                        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
//                                        if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                                            zgzAmount.add(BigDecimal.ZERO);
//                                        } else {
//                                            zgzAmount = zgzAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
//                                        }
//
//                                    }
//                                }
//                            }
//                            sf = sf.add(zgzAmount);
//                            yf = yf.add(zgzAmount);
//
//                        }
//                    } else {
//                        BigDecimal zAmount = BigDecimal.ZERO;
//                        HrmSalaryFixed hrmSalaryFixed1 = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//                            eq(HrmSalaryFixed::getEmployeeId, e);
//                            eq(HrmSalaryFixed::getIsEffect, 1);
//                            orderByDesc(HrmSalaryFixed::getDate);
//                            last("limit 1");
//                        }});
//                        HrmSalaryFixed finalHrmSalaryFixed = hrmSalaryFixed1;
//                        List<HrmSalaryFixedTable> hrmSalaryFixedTables1 = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                            eq(HrmSalaryFixedTable::getFixedId, finalHrmSalaryFixed.getId());
//                        }});
//                        for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTables1) {
//                            HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
//                            if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                                zAmount = zAmount.add(BigDecimal.ZERO);
//                            } else {
//                                zAmount = zAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
//                            }
//
//                        }
//                        sf = sf.add(zAmount);
//                        yf = yf.add(zAmount);
//                    }
//                }
//                List<HrmSalaryRecordEmployeeTable> hrmSalaryRecordEmployeeTables = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
//                    eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee.getId());
//                }});
//                System.err.println("实发工资==========================================" + sf);
//                for (int j = 0; j < hrmSalaryRecordEmployeeTables.size(); j++) {
//                    HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryRecordEmployeeTables.get(j).getTableId());
//                    HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = hrmSalaryRecordEmployeeTableMapper.selectOne(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
//                        eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee.getId());
//                        eq(HrmSalaryRecordEmployeeTable::getTableId, hrmSalaryTableConfigTenant.getId());
//                        last("limit 1");
//                    }});
//                    if (ObjectUtils.isEmpty(hrmSalaryRecordEmployeeTable)) {
//                        continue;
//                    }
//                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
//                    switch (hrmSalaryTableConfigTenant.getDistinguish()) {
//                        //考勤扣款多少钱暂时手填预留出来
//                        case 12:
//                            kqKK.add(BigDecimal.ZERO);
//                            hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                            sf = sf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            yf = yf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            break;
//                        case 13:
//                            kqKK.add(BigDecimal.ZERO);
//                            hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                            sf = sf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            yf = yf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            break;
//                        case 14:
//                            kqKK.add(BigDecimal.ZERO);
//                            hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                            sf = sf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            yf = yf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            break;
//                        case 15:
//                            kqKK.add(BigDecimal.ZERO);
//                            hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                            sf = sf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            yf = yf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            break;
//                        case 16:
//                            kqKK.add(BigDecimal.ZERO);
//                            hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                            sf = sf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            yf = yf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            break;
//                        case 18:
//                            kqKK.add(BigDecimal.ZERO);
//                            hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                            hrmSalaryRecordEmployeeTable.setValue(kqKK);
//                            break;
//                        //个人社保
//                        case 68:
//                            hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                            sf = sf.subtract(grSb);
//                            hrmSalaryRecordEmployeeTable.setValue(grSb);
//                            break;
//                        //个人公积金
//                        case 69:
//                            hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                            sf = sf.subtract(grGjj);
//                            hrmSalaryRecordEmployeeTable.setValue(grGjj);
//                            break;
//                        case 39:
//
//                            break;
//                        case 40:
//
//                            break;
//                        case 41:
//
//                            break;
//                        default:
//                            if (hrmSalaryTableConfigTenant.getIsAddSubtract() == 1) {
//                                hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                                sf = sf.add(hrmSalaryRecordEmployeeTable.getValue());
//                                yf = yf.add(hrmSalaryRecordEmployeeTable.getValue());
//                            } else if (hrmSalaryTableConfigTenant.getIsAddSubtract() == 2) {
//                                hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                                sf = sf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                                yf = yf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            }
//                    }
//                    hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTable);
//                }
//                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenantYF = hrmSalaryTableConfigTenantMapper.selectOne(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
//                    eq(HrmSalaryTableConfigTenant::getDistinguish, 19);
//                }});
//
//                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenantKQKK = hrmSalaryTableConfigTenantMapper.selectOne(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
//                    eq(HrmSalaryTableConfigTenant::getDistinguish, 18);
//                }});
//
//                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenantSF = hrmSalaryTableConfigTenantMapper.selectOne(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
//                    eq(HrmSalaryTableConfigTenant::getDistinguish, 22);
//                }});
//                HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTableYF = hrmSalaryRecordEmployeeTableMapper.selectOne(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
//                    eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee.getId());
//                    eq(HrmSalaryRecordEmployeeTable::getTableId, hrmSalaryTableConfigTenantYF.getId());
//                    last("limit 1");
//                }});
//                hrmSalaryRecordEmployeeTableYF.setValue(yf);
//                hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTableYF);
//                HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTableSF = hrmSalaryRecordEmployeeTableMapper.selectOne(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
//                    eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee.getId());
//                    eq(HrmSalaryRecordEmployeeTable::getTableId, hrmSalaryTableConfigTenantSF.getId());
//                    last("limit 1");
//                }});
//                hrmSalaryRecordEmployeeTableSF.setValue(sf);
//                hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTableSF);
//
//
//                HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTableKQKK = hrmSalaryRecordEmployeeTableMapper.selectOne(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
//                    eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee.getId());
//                    eq(HrmSalaryRecordEmployeeTable::getTableId, hrmSalaryTableConfigTenantKQKK.getId());
//                    last("limit 1");
//                }});
//                hrmSalaryRecordEmployeeTableKQKK.setValue(kqKK);
//                hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTableKQKK);
//
//            } else {
//                HrmSalaryFixed hrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//                    eq(HrmSalaryFixed::getEmployeeId, e);
//                    eq(HrmSalaryFixed::getIsEffect, 1);
//                    orderByDesc(HrmSalaryFixed::getDate);
//                    last("limit 1");
//                }});
//                if (ObjectUtils.isEmpty(hrmSalaryFixed)) {
//                    HrmSalaryRecordEmployee hrmSalaryRecordEmployee = new HrmSalaryRecordEmployee();
//                    hrmSalaryRecordEmployee.setRecordId(hrmSalaryRecord.getId());
//                    hrmSalaryRecordEmployee.setEmployeeId(e);
//                    hrmSalaryRecordEmployee.setEmployeeName(employeeDO.getName());
//                    hrmSalaryRecordEmployee.setEmployeeNo(employeeDO.getEmployeeNo());
//                    hrmSalaryRecordEmployee.setDepartmentId(employeeDO.getDeptId().intValue());
//                    hrmSalaryRecordEmployee.setPostId(employeeDO.getPostId().intValue());
//                    hrmSalaryRecordEmployee.setCreateTime(DateUtil.currentDateFormat());
//                    hrmSalaryRecordEmployee.setCreateBy(loginEmployee.getId().intValue());
//                    hrmSalaryRecordEmployeeMapper.insert(hrmSalaryRecordEmployee);
//                    List<HrmSalaryTableConfigTenant> hrmSalaryTableConfigTenants = hrmSalaryTableConfigTenantMapper.selectList(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
//                        eq(HrmSalaryTableConfigTenant::getIsDisplayed, 1);
//                        ne(HrmSalaryTableConfigTenant::getPid, 0);
//                        orderByAsc(HrmSalaryTableConfigTenant::getTableOrder);
//                    }});
//                    for (int i = 0; i < hrmSalaryTableConfigTenants.size(); i++) {
//                        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryTableConfigTenants.get(i).getId());
//                        if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                            continue;
//                        }
//                        HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
//                        hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenants.get(i).getId());
//                        hrmSalaryRecordEmployeeTable.setValue(BigDecimal.ZERO);
//                        hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
//                        hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
//                    }
//                    continue;
//                }
//                HrmSalaryRecordEmployee hrmSalaryRecordEmployee = new HrmSalaryRecordEmployee();
//                hrmSalaryRecordEmployee.setRecordId(hrmSalaryRecord.getId());
//                hrmSalaryRecordEmployee.setSalaryFixedId(hrmSalaryFixed.getId());
//                hrmSalaryRecordEmployee.setEmployeeId(e);
//                hrmSalaryRecordEmployee.setEmployeeName(employeeDO.getName());
//                hrmSalaryRecordEmployee.setEmployeeNo(employeeDO.getEmployeeNo());
//                hrmSalaryRecordEmployee.setDepartmentId(employeeDO.getDeptId().intValue());
//                hrmSalaryRecordEmployee.setPostId(employeeDO.getPostId().intValue());
//                hrmSalaryRecordEmployee.setCreateTime(DateUtil.currentDateFormat());
//                hrmSalaryRecordEmployee.setCreateBy(loginEmployee.getId().intValue());
//                hrmSalaryRecordEmployeeMapper.insert(hrmSalaryRecordEmployee);
//                //设置的员工基本项工资
//                List<HrmSalaryFixedTable> hrmSalaryFixedTables = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                    eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed.getId());
//                }});
//                EmployeeSeparationRecordDO employeeSeparationRecordDO = employeeSeparationRecordMapper.selectOne(new LambdaQueryWrapper<EmployeeSeparationRecordDO>() {{
//                    eq(EmployeeSeparationRecordDO::getEmployeeId, employeeDO.getId());
//                    eq(EmployeeSeparationRecordDO::getDeleted, 0);
//                    eq(EmployeeSeparationRecordDO::getApproveResult, 2);
//
//                }});
//                if (employeeDO.getState() == 3 || (!ObjectUtils.isEmpty(employeeSeparationRecordDO) && employeeSeparationRecordDO.getOldEmployeeState() == 3)) {
//                    employeeStatus = 1;
//                } else {
//                    employeeStatus = 0;
//                }
//                List<HrmSalaryTableConfigTenant> hrmSalaryTableConfigTenants = hrmSalaryTableConfigTenantMapper.selectList(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
//                    eq(HrmSalaryTableConfigTenant::getIsDisplayed, 1);
//                    ne(HrmSalaryTableConfigTenant::getPid, 0);
//                    orderByAsc(HrmSalaryTableConfigTenant::getTableOrder);
//                }});
//                for (int i = 0; i < hrmSalaryTableConfigTenants.size(); i++) {
//                    HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryTableConfigTenants.get(i).getId());
//                    if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                        continue;
//                    }
//                    HrmSalaryFixedTable hrmSalaryFixedTable = hrmSalaryFixedTableMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                        eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed.getId());
//                        eq(HrmSalaryFixedTable::getTableId, hrmSalaryTableConfigTenant.getId());
//                    }});
//                    HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
//                    hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenants.get(i).getId());
//                    if (employeeStatus == 0 && !ObjectUtils.isEmpty(hrmSalaryFixedTable)) {
//                        hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeFrontAmount());
//                    } else if (employeeStatus == 1 && !ObjectUtils.isEmpty(hrmSalaryFixedTable)) {
//                        hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
//                    }
//                    hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
//                    hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
//                }
//                HrmProgrammeEmployeeRecord hrmProgrammeEmployeeRecord = hrmProgrammeEmployeeRecordMapper.selectOne(new LambdaQueryWrapper<HrmProgrammeEmployeeRecord>() {{
//                    eq(HrmProgrammeEmployeeRecord::getEmployeeId, e);
//                    if (salarySetting.getType() == 1) {
//                        LocalDate localDate = LocalDate.parse(date + "-01", DateTimeFormatter.ISO_LOCAL_DATE);
//                        LocalDate previousMonth = localDate.minusMonths(1);
//                        String previousMonthStr = previousMonth.format(DateTimeFormatter.ofPattern("yyyy-MM"));
//                        eq(HrmProgrammeEmployeeRecord::getProgrammeStartTime, previousMonthStr);
//                    } else if (salarySetting.getType() == 2) {
//                        eq(HrmProgrammeEmployeeRecord::getProgrammeStartTime, date);
//                    }
//                    last("limit 1");
//                }});
//
//                if (!ObjectUtils.isEmpty(hrmProgrammeEmployeeRecord)) {
//                    accountGjj = hrmProgrammeEmployeeRecord.getAccumulationAmount();
//                    grGjj = hrmProgrammeEmployeeRecord.getEmployeeAccumulationAmount();
//                    accountSb = hrmProgrammeEmployeeRecord.getAccumulationAmount();
//                    grSb = hrmProgrammeEmployeeRecord.getEmployeeAccumulationAmount();
//                }
//                LocalDateTime regularizationTime = employeeDO.getRegularizationTime();
//                if (ObjectUtils.isEmpty(regularizationTime)) {
//                    HrmSalaryFixed hrmSalaryFixed1 = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//                        eq(HrmSalaryFixed::getEmployeeId, e);
//                        eq(HrmSalaryFixed::getIsEffect, 1);
//                        orderByDesc(HrmSalaryFixed::getDate);
//                        last("limit 1");
//                    }});
//                    if (!ObjectUtils.isEmpty(hrmSalaryFixed1)) {
//                        List<HrmSalaryFixedTable> hrmSalaryFixedTables1 = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                            eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed1.getId());
//                        }});
//                        for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTables1) {
//                            HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTables.get(0).getTableId());
//                            if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                                continue;
//                            }
//                            sf = sf.add(hrmSalaryFixedTable.getBecomeFrontAmount());
//                            yf = yf.add(hrmSalaryFixedTable.getBecomeFrontAmount());
//                        }
//                    }
//                } else {
//                    Long zzTime = employeeDO.getRegularizationTime().toEpochSecond(java.time.ZoneOffset.UTC) * 1000;
//                    long dateStart = DateUtil.strYearMonth(date + "-01");
//                    long dateEnd = DateUtil.strYearMonth(date + "-31");
//                    //看是不是生成工资月转正的
//                    if (zzTime >= dateStart && zzTime <= dateEnd) {
//                        if (hrmSalaryPlan.getSalaryAdjustmentRules() == 1) {
//                            BigDecimal syqZgz = BigDecimal.ZERO;
//                            BigDecimal zzhZgz = BigDecimal.ZERO;
//                            HrmSalaryFixed hrmSalaryFixed1 = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//                                eq(HrmSalaryFixed::getEmployeeId, e);
//                                le(HrmSalaryFixed::getDate, DateUtil.longToString(zzTime));
//                                eq(HrmSalaryFixed::getIsEffect, 1);
//                                last("limit 1");
//                            }});
//                            //上半个月出勤天数
//                            List<DingColumnValue> sbMonthDingColumnValues = dingColumnValueMapper.selectList(new QueryWrapper<DingColumnValue>() {{
//                                select("if (sum( column_value ) =0,column_value,sum( column_value )) AS columnValue,\n" +
//                                        "\tcolumn_id columnId  ");
//                                ge("date", date + "-01 00:00:00");
//                                le("date", DateUtil.longToString(zzTime));
//                                eq("ding_user_id", employeeDO.getDingUserId());
//                                eq("column_id", 17);
//                                groupBy("ding_user_id,column_id");
//                            }});
//
//                            if (ObjectUtils.isEmpty(sbMonthDingColumnValues)) {
//                                sbMonthDingColumnValues = new ArrayList<>();
//                                DingColumnValue dingColumnValue = new DingColumnValue();
//                                dingColumnValue.setColumnValue("0");
//                                dingColumnValue.setColumnId(17);
//                                sbMonthDingColumnValues.add(dingColumnValue);
//
//                            }
//                            List<DingColumnValue> sbycdingColumnValues = dingColumnValueMapper.selectList(new QueryWrapper<DingColumnValue>() {{
//                                select("if (sum( column_value ) =0,column_value,sum( column_value )) AS columnValue,\n" +
//                                        "\tcolumn_id columnId  ");
//                                ge("date", date + "-01 00:00:00");
//                                le("date", date + "-31 23:59:59");
//                                eq("ding_user_id", employeeDO.getDingUserId());
//                                eq("column_id", 44);
//                                groupBy("ding_user_id,column_id");
//                            }});
//                            if (!ObjectUtils.isEmpty(hrmSalaryFixed1)) {
//                                if (ObjectUtils.isEmpty(sbycdingColumnValues)) {
//                                    sbycdingColumnValues = new ArrayList<>();
//                                    DingColumnValue dingColumnValue = new DingColumnValue();
//                                    dingColumnValue.setColumnValue("0");
//                                    dingColumnValue.setColumnId(44);
//                                    sbycdingColumnValues.add(dingColumnValue);
//                                }
//
//                                HrmSalaryFixed finalHrmSalaryFixed = hrmSalaryFixed1;
//                                List<HrmSalaryFixedTable> hrmSalaryFixedTables1 = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                                    eq(HrmSalaryFixedTable::getFixedId, finalHrmSalaryFixed.getId());
//                                }});
//                                for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTables1) {
//                                    HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
//                                    if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                                        continue;
//                                    }
//                                    syqZgz = syqZgz.add(hrmSalaryFixedTable.getBecomeFrontAmount());
//                                }
//                            }
//                            BigDecimal bigDecimal = new BigDecimal(sbycdingColumnValues.get(0).getColumnValue());
//                            BigDecimal bigDecimal1 = new BigDecimal(sbMonthDingColumnValues.get(0).getColumnValue());
//                            if (ObjectUtils.isEmpty(bigDecimal) || bigDecimal1.compareTo(BigDecimal.ZERO) == 0) {
//                                sf = sf.add(BigDecimal.ZERO);
//                                yf = yf.add(BigDecimal.ZERO);
//                            } else {
//                                sf = sf.add(syqZgz.divide(bigDecimal, 2, BigDecimal.ROUND_HALF_UP).multiply(bigDecimal1));
//                                yf = yf.add(syqZgz.divide(bigDecimal, 2, BigDecimal.ROUND_HALF_UP).multiply(bigDecimal1));
//                            }
//                            List<DingColumnValue> xbMonthDingColumnValues = dingColumnValueMapper.selectList(new QueryWrapper<DingColumnValue>() {{
//                                select("if (sum( column_value ) =0,column_value,sum( column_value )) AS columnValue,\n" +
//                                        "\tcolumn_id columnId  ");
//                                ge("date", date + "-01 00:00:00");
//                                le("date", date + "-31 23:59:59");
//                                eq("ding_user_id", employeeDO.getDingUserId());
//                                eq("column_id", 44);
//                                groupBy("ding_user_id,column_id");
//                            }});
//                            if (ObjectUtils.isEmpty(xbMonthDingColumnValues)) {
//                                xbMonthDingColumnValues = new ArrayList<>();
//                                DingColumnValue dingColumnValue = new DingColumnValue();
//                                dingColumnValue.setColumnValue("0");
//                                dingColumnValue.setColumnId(44);
//                                xbMonthDingColumnValues.add(dingColumnValue);
//                            }
//                            List<DingColumnValue> xbdingColumnValues = dingColumnValueMapper.selectList(new QueryWrapper<DingColumnValue>() {{
//                                select("if (sum( column_value ) =0,column_value,sum( column_value )) AS columnValue,\n" +
//                                        "\tcolumn_id columnId  ");
//                                ge("date", DateUtil.longToString(zzTime));
//                                le("date", date + "-31 23:59:59");
//                                eq("ding_user_id", employeeDO.getDingUserId());
//                                eq("column_id", 17);
//                                groupBy("ding_user_id,column_id");
//                            }});
//                            if (ObjectUtils.isEmpty(xbdingColumnValues)) {
//                                xbdingColumnValues = new ArrayList<>();
//                                DingColumnValue dingColumnValue = new DingColumnValue();
//                                dingColumnValue.setColumnValue("0");
//                                dingColumnValue.setColumnId(17);
//                                xbdingColumnValues.add(dingColumnValue);
//                            }
//                            hrmSalaryFixed1 = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//                                eq(HrmSalaryFixed::getEmployeeId, e);
//                                orderByDesc(HrmSalaryFixed::getDate);
//                                eq(HrmSalaryFixed::getIsEffect, 1);
//                                last("limit 1");
//                            }});
//                            HrmSalaryFixed finalHrmSalaryFixed = hrmSalaryFixed1;
//                            List<HrmSalaryFixedTable> hrmSalaryFixedTables1 = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                                eq(HrmSalaryFixedTable::getFixedId, finalHrmSalaryFixed.getId());
//                            }});
//                            for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTables1) {
//                                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
//                                if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                                    continue;
//                                }
//                                zzhZgz = zzhZgz.add(hrmSalaryFixedTable.getBecomeAfterAmount());
//                            }
//                            bigDecimal = new BigDecimal(xbMonthDingColumnValues.get(0).getColumnValue());
//                            bigDecimal1 = (new BigDecimal(xbdingColumnValues.get(0).getColumnValue()));
//                            if (ObjectUtils.isEmpty(bigDecimal) || bigDecimal1.compareTo(BigDecimal.ZERO) == 0) {
//                                sf = sf.add(BigDecimal.ZERO);
//                                yf = yf.add(BigDecimal.ZERO);
//                            } else {
//                                sf = sf.add(zzhZgz.divide(bigDecimal, 2, BigDecimal.ROUND_HALF_UP).multiply(bigDecimal1));
//                                yf = yf.add(zzhZgz.divide(bigDecimal, 2, BigDecimal.ROUND_HALF_UP).multiply(bigDecimal1));
//                            }
//
//                        } else if (hrmSalaryPlan.getSalaryAdjustmentRules() == 2) {
//                            BigDecimal zzhZAmount = BigDecimal.ZERO;
//                            HrmSalaryFixed hrmSalaryFixed1 = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//                                eq(HrmSalaryFixed::getEmployeeId, e);
//                                eq(HrmSalaryFixed::getIsEffect, 1);
//                                orderByDesc(HrmSalaryFixed::getDate);
//                                last("limit 1");
//                            }});
//                            //上半个月出勤天数
//                            List<DingColumnValue> monthDingColumnValues = dingColumnValueMapper.selectList(new QueryWrapper<DingColumnValue>() {{
//                                select("if (sum( column_value ) =0,column_value,sum( column_value )) AS columnValue,\n" +
//                                        "\tcolumn_id columnId  ");
//                                ge("date", date + "-01 00:00:00");
//                                le("date", date + "-31 23:59:59");
//                                eq("ding_user_id", employeeDO.getDingUserId());
//                                eq("column_id", 17);
//                                groupBy("ding_user_id,column_id");
//                            }});
//                            List<DingColumnValue> zdingColumnValues = dingColumnValueMapper.selectList(new QueryWrapper<DingColumnValue>() {{
//                                select("if (sum( column_value ) =0,column_value,sum( column_value )) AS columnValue,\n" +
//                                        "\tcolumn_id columnId  ");
//                                ge("date", date + "-01 00:00:00");
//                                le("date", date + "-31 23:59:59");
//                                eq("ding_user_id", employeeDO.getDingUserId());
//                                eq("column_id", 44);
//                                groupBy("ding_user_id,column_id");
//                            }});
//                            if (ObjectUtils.isEmpty(monthDingColumnValues)) {
//                                monthDingColumnValues = new ArrayList<>();
//                                DingColumnValue dingColumnValue = new DingColumnValue();
//                                dingColumnValue.setColumnValue("0");
//                                dingColumnValue.setColumnId(17);
//                                monthDingColumnValues.add(dingColumnValue);
//                            }
//                            if (ObjectUtils.isEmpty(zdingColumnValues)) {
//                                zdingColumnValues = new ArrayList<>();
//                                DingColumnValue dingColumnValue = new DingColumnValue();
//                                dingColumnValue.setColumnValue("0");
//                                dingColumnValue.setColumnId(44);
//                                zdingColumnValues.add(dingColumnValue);
//                            }
//                            List<HrmSalaryFixedTable> hrmSalaryFixedTables1 = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                                eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed1.getId());
//                            }});
//                            for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTables1) {
//                                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
//                                if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                                    continue;
//                                }
//                                zzhZAmount = zzhZAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
//                            }
//
//                            BigDecimal bigDecimal = new BigDecimal(zdingColumnValues.get(0).getColumnValue());
//                            BigDecimal bigDecimal1 = (new BigDecimal(monthDingColumnValues.get(0).getColumnValue()));
//                            if (ObjectUtils.isEmpty(bigDecimal) || bigDecimal1.compareTo(BigDecimal.ZERO) == 0) {
//                                sf = sf.add(BigDecimal.ZERO);
//                                yf = yf.add(BigDecimal.ZERO);
//                            } else {
//                                sf = sf.add(zzhZAmount.divide(bigDecimal, 2, BigDecimal.ROUND_HALF_UP).multiply(bigDecimal1));
//                                yf = yf.add(zzhZAmount.divide(bigDecimal, 2, BigDecimal.ROUND_HALF_UP).multiply(bigDecimal1));
//                            }
//
//                        } else if (hrmSalaryPlan.getSalaryAdjustmentRules() == 3) {
//                            BigDecimal zgzAmount = BigDecimal.ZERO;
//                            Long l = DateUtil.strZLong(date + "-15");
//                            if (zzTime < l) {
//                                HrmSalaryFixed hrmSalaryFixed1 = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//                                    eq(HrmSalaryFixed::getEmployeeId, e);
////                        le(HrmSalaryFixed::getDate, DateUtil.longToString(zzTime));
//                                    eq(HrmSalaryFixed::getIsEffect, 1);
//                                    orderByDesc(HrmSalaryFixed::getDate);
//                                    last("limit 1");
//                                }});
//                                List<HrmSalaryFixedTable> hrmSalaryFixedTables1 = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                                    eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed1.getId());
//                                }});
//                                for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTables1) {
//                                    HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
//                                    if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                                        continue;
//                                    }
//                                    zgzAmount = zgzAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
//                                }
//
//
//                            } else {
//                                HrmSalaryFixed hrmSalaryFixed1 = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//                                    eq(HrmSalaryFixed::getEmployeeId, e);
//                                    le(HrmSalaryFixed::getDate, DateUtil.longToString(zzTime));
//                                    eq(HrmSalaryFixed::getIsEffect, 1);
//                                    orderByDesc(HrmSalaryFixed::getDate);
//                                    last("limit 1");
//                                }});
//                                if (ObjectUtils.isEmpty(hrmSalaryFixed1)) {
//                                    HrmSalaryFixed hrmSalaryFixed2 = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//                                        eq(HrmSalaryFixed::getEmployeeId, e);
////                                 le(HrmSalaryFixed::getDate, DateUtil.longToString(zzTime));
//                                        eq(HrmSalaryFixed::getIsEffect, 1);
//                                        orderByDesc(HrmSalaryFixed::getDate);
//                                        last("limit 1");
//                                    }});
//
//                                    List<HrmSalaryFixedTable> hrmSalaryFixedTables1 = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                                        eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed2.getId());
//                                    }});
//                                    for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTables1) {
//                                        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
//                                        if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                                            continue;
//                                        }
//                                        zgzAmount = zgzAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
//                                    }
//                                } else {
//                                    List<HrmSalaryFixedTable> hrmSalaryFixedTables1 = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                                        eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed1.getId());
//                                    }});
//                                    for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTables1) {
//                                        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
//                                        if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                                            continue;
//                                        }
//                                        zgzAmount = zgzAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
//                                    }
//                                }
//                            }
//
//                            List<DingColumnValue> sbMonthDingColumnValues = dingColumnValueMapper.selectList(new QueryWrapper<DingColumnValue>() {{
//                                select("if (sum( column_value ) =0,column_value,sum( column_value )) AS columnValue,\n" +
//                                        "\tcolumn_id columnId  ");
//                                ge("date", date + "-01 00:00:00");
//                                le("date", date + "-31 23:59:59");
//                                eq("ding_user_id", employeeDO.getDingUserId());
//                                eq("column_id", 17);
//                                groupBy("ding_user_id,column_id");
//                            }});
//                            List<DingColumnValue> sbycdingColumnValues = dingColumnValueMapper.selectList(new QueryWrapper<DingColumnValue>() {{
//                                select("if (sum( column_value ) =0,column_value,sum( column_value )) AS columnValue,\n" +
//                                        "\tcolumn_id columnId  ");
//                                ge("date", date + "-01 00:00:00");
//                                le("date", date + "-31 23:59:59");
//                                eq("ding_user_id", employeeDO.getDingUserId());
//                                eq("column_id", 44);
//                                groupBy("ding_user_id,column_id");
//                            }});
//                            if (ObjectUtils.isEmpty(sbMonthDingColumnValues)) {
//                                sbMonthDingColumnValues = new ArrayList<>();
//                                DingColumnValue dingColumnValue = new DingColumnValue();
//                                dingColumnValue.setColumnValue("0");
//                                dingColumnValue.setColumnId(17);
//                                sbMonthDingColumnValues.add(dingColumnValue);
//                            }
//                            if (ObjectUtils.isEmpty(sbycdingColumnValues)) {
//                                sbycdingColumnValues = new ArrayList<>();
//                                DingColumnValue dingColumnValue = new DingColumnValue();
//                                dingColumnValue.setColumnValue("0");
//                                dingColumnValue.setColumnId(44);
//                                sbycdingColumnValues.add(dingColumnValue);
//                            }
//
//                            BigDecimal bigDecimal = new BigDecimal(sbycdingColumnValues.get(0).getColumnValue());
//                            BigDecimal bigDecimal1 = (new BigDecimal(sbMonthDingColumnValues.get(0).getColumnValue()));
//                            if (ObjectUtils.isEmpty(bigDecimal) || bigDecimal1.compareTo(BigDecimal.ZERO) == 0) {
//                                sf = sf.add(BigDecimal.ZERO);
//                                yf = yf.add(BigDecimal.ZERO);
//                            } else {
//                                sf = sf.add(zgzAmount.divide(bigDecimal, 2, BigDecimal.ROUND_HALF_UP).multiply(bigDecimal1));
//                                yf = yf.add(zgzAmount.divide(bigDecimal, 2, BigDecimal.ROUND_HALF_UP).multiply(bigDecimal1));
//                            }
//                        }
//                    } else {
//                        BigDecimal zAmount = BigDecimal.ZERO;
//                        List<DingColumnValue> xbMonthDingColumnValues = dingColumnValueMapper.selectList(new QueryWrapper<DingColumnValue>() {{
//                            select("if (sum( column_value ) =0,column_value,sum( column_value )) AS columnValue,\n" +
//                                    "\tcolumn_id columnId  ");
//                            ge("date", date + "-01 00:00:00");
//                            le("date", date + "-31 23:59:59");
//                            eq("ding_user_id", employeeDO.getDingUserId());
//                            eq("column_id", 44);
//                            groupBy("ding_user_id,column_id");
//                        }});
//                        if (ObjectUtils.isEmpty(xbMonthDingColumnValues)) {
//                            xbMonthDingColumnValues = new ArrayList<>();
//                            DingColumnValue dingColumnValue = new DingColumnValue();
//                            dingColumnValue.setColumnValue("0");
//                            dingColumnValue.setColumnId(44);
//                            xbMonthDingColumnValues.add(dingColumnValue);
//                        }
//
//                        List<DingColumnValue> xbdingColumnValues = dingColumnValueMapper.selectList(new QueryWrapper<DingColumnValue>() {{
//                            select("if (sum( column_value ) =0,column_value,sum( column_value )) AS columnValue,\n" +
//                                    "\tcolumn_id columnId  ");
//                            ge("date", date + "-01 00:00:00");
//                            le("date", date + "-31 23:59:59");
//                            eq("ding_user_id", employeeDO.getDingUserId());
//                            eq("column_id", 17);
//                            groupBy("ding_user_id,column_id");
//                        }});
//                        if (ObjectUtils.isEmpty(xbdingColumnValues)) {
//                            xbdingColumnValues = new ArrayList<>();
//                            DingColumnValue dingColumnValue = new DingColumnValue();
//                            dingColumnValue.setColumnValue("0");
//                            dingColumnValue.setColumnId(17);
//                            xbdingColumnValues.add(dingColumnValue);
//                        }
//                        HrmSalaryFixed hrmSalaryFixed1 = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//                            eq(HrmSalaryFixed::getEmployeeId, e);
//                            eq(HrmSalaryFixed::getIsEffect, 1);
//                            orderByDesc(HrmSalaryFixed::getDate);
//                            last("limit 1");
//                        }});
//
//                        HrmSalaryFixed finalHrmSalaryFixed = hrmSalaryFixed1;
//                        List<HrmSalaryFixedTable> hrmSalaryFixedTables1 = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                            eq(HrmSalaryFixedTable::getFixedId, finalHrmSalaryFixed.getId());
//                        }});
//                        for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTables1) {
//                            HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
//                            if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                                continue;
//                            }
//
//                            zAmount = zAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
//
//
//                        }
//                        BigDecimal bigDecimal = new BigDecimal(xbMonthDingColumnValues.get(0).getColumnValue());
//                        BigDecimal bigDecimal1 = (new BigDecimal(xbdingColumnValues.get(0).getColumnValue()));
//                        if (ObjectUtils.isEmpty(bigDecimal) || bigDecimal1.compareTo(BigDecimal.ZERO) == 0) {
//                            sf = sf.add(BigDecimal.ZERO);
//                            yf = yf.add(BigDecimal.ZERO);
//                        } else if (bigDecimal.compareTo(bigDecimal1) != 0) {
//                            sf = sf.add(zAmount.divide(bigDecimal, 0, BigDecimal.ROUND_HALF_UP).multiply(bigDecimal1));
//                            yf = yf.add(zAmount.divide(bigDecimal, 0, BigDecimal.ROUND_HALF_UP).multiply(bigDecimal1));
//                        } else {
//                            sf = sf.add(zAmount);
//                            yf = yf.add(zAmount);
//                        }
//                    }
//
//                }
//                List<HrmSalaryRecordEmployeeTable> hrmSalaryRecordEmployeeTables = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
//                    eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee.getId());
//                }});
//                System.err.println("实发工资==========================================" + sf);
//                for (int j = 0; j < hrmSalaryRecordEmployeeTables.size(); j++) {
//                    HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryRecordEmployeeTables.get(j).getTableId());
//                    HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = hrmSalaryRecordEmployeeTableMapper.selectOne(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
//                        eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee.getId());
//                        eq(HrmSalaryRecordEmployeeTable::getTableId, hrmSalaryTableConfigTenant.getId());
//                        last("limit 1");
//                    }});
//                    if (ObjectUtils.isEmpty(hrmSalaryRecordEmployeeTable)) {
//                        continue;
//                    }
//                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
//                    switch (hrmSalaryTableConfigTenant.getDistinguish()) {
//                        //考勤扣款多少钱暂时手填预留出来
//                        case 12:
//                            kqKK = kqKK.add(BigDecimal.ZERO);
//                            hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                            sf = sf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            yf = yf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            break;
//                        case 13:
//                            kqKK = kqKK.add(BigDecimal.ZERO);
//                            hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                            sf = sf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            yf = yf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            break;
//                        case 14:
//                            kqKK = kqKK.add(BigDecimal.ZERO);
//                            hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                            sf = sf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            yf = yf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            break;
//                        case 15:
//                            kqKK = kqKK.add(BigDecimal.ZERO);
//                            hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                            sf = sf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            yf = yf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            break;
//                        case 16:
//                            kqKK = kqKK.add(BigDecimal.ZERO);
//                            hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                            sf = sf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            yf = yf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            break;
//                        case 18:
//                            kqKK.add(BigDecimal.ZERO);
//                            hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                            hrmSalaryRecordEmployeeTable.setValue(kqKK);
//                            break;
//                        //个人社保
//                        case 68:
//                            hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                            sf = sf.subtract(grSb);
//                            hrmSalaryRecordEmployeeTable.setValue(grSb);
//                            break;
//                        //个人公积金
//                        case 69:
//                            hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                            sf = sf.subtract(grGjj);
//                            hrmSalaryRecordEmployeeTable.setValue(grGjj);
//                            break;
//                        case 39:
//
//                            break;
//                        case 40:
//
//                            break;
//                        case 41:
//
//                            break;
//                        default:
//                            if (hrmSalaryTableConfigTenant.getIsAddSubtract() == 1) {
//                                hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                                sf = sf.add(hrmSalaryRecordEmployeeTable.getValue());
//                                yf = yf.add(hrmSalaryRecordEmployeeTable.getValue());
//                            } else if (hrmSalaryTableConfigTenant.getIsAddSubtract() == 2) {
//                                hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                                sf = sf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                                yf = yf.subtract(hrmSalaryRecordEmployeeTable.getValue());
//                            }
//                    }
//                    hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTable);
//                }
//                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenantYF = hrmSalaryTableConfigTenantMapper.selectOne(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
//                    eq(HrmSalaryTableConfigTenant::getDistinguish, 19);
//                }});
//                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenantKQKK = hrmSalaryTableConfigTenantMapper.selectOne(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
//                    eq(HrmSalaryTableConfigTenant::getDistinguish, 18);
//                }});
//                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenantSF = hrmSalaryTableConfigTenantMapper.selectOne(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
//                    eq(HrmSalaryTableConfigTenant::getDistinguish, 22);
//                }});
//                HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTableYF = hrmSalaryRecordEmployeeTableMapper.selectOne(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
//                    eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee.getId());
//                    eq(HrmSalaryRecordEmployeeTable::getTableId, hrmSalaryTableConfigTenantYF.getId());
//                    last("limit 1");
//                }});
//                hrmSalaryRecordEmployeeTableYF.setValue(yf);
//                hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTableYF);
//                HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTableSF = hrmSalaryRecordEmployeeTableMapper.selectOne(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
//                    eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee.getId());
//                    eq(HrmSalaryRecordEmployeeTable::getTableId, hrmSalaryTableConfigTenantSF.getId());
//                    last("limit 1");
//                }});
//                hrmSalaryRecordEmployeeTableSF.setValue(sf);
//                hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTableSF);
//                HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTableKQKK = hrmSalaryRecordEmployeeTableMapper.selectOne(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
//                    eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee.getId());
//                    eq(HrmSalaryRecordEmployeeTable::getTableId, hrmSalaryTableConfigTenantKQKK.getId());
//                    last("limit 1");
//                }});
//                hrmSalaryRecordEmployeeTableKQKK.setValue(kqKK);
//                hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTableKQKK);
//            }
//        }
    }

        @Override
        public void initSystemColumnTenant(String tenantId) {
//        systemColumnMapper.
        }

    @Override
    @DataPermission(enable = false)
    public void generateSalaryRecordNew(Integer type, List<Integer> employeeId, String date,Integer hsType) {
        if(hsType==1){
            if (type == 1) {
                employeeId = employeeMapper.selectList().stream().map(e -> e.getId().intValue()).collect(Collectors.toList());
            }
            List<Integer> effectiveEmployeeId = new ArrayList<>();
            Long loginId = SecurityFrameworkUtils.getLoginUserId();
            EmployeeDO loginEmployee = employeeMapper.selectOne(new LambdaQueryWrapper<EmployeeDO>() {{
                eq(EmployeeDO::getUserId, loginId);
            }});
            String createData = DateUtil.formatDateByYear(date);
            Long l1 = hrmSalaryRecordMapper.selectCount(new LambdaQueryWrapper<HrmSalaryRecord>() {{
                eq(HrmSalaryRecord::getEmployeeId, loginId);
                eq(HrmSalaryRecord::getCreatTime, createData);
            }});
            if (l1 > 0) {
                throw new ResultException(date + "工资数据已存在");
            }
            if (ObjectUtils.isEmpty(loginEmployee)) {
                throw new ResultException("当前登录账号不可以创建生成薪资");
            }
            for (int i = 0; i < employeeId.size(); i++) {
                //查看当前生成薪资人员是否存在
                EmployeeDO employeeDO = employeeMapper.selectByUserId(employeeId.get(i).longValue());
                if (ObjectUtils.isEmpty(employeeDO)) {
                    throw new ResultException("当前生成薪资人员不存在");
                    //不存在则跳过
//                continue;
                }
                Long l = hrmSalaryFixedMapper.selectCount(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
                }});
                if (l <= 0) {
                    throw new ResultException("存在异常人员");
                }
                //查看生成薪资人员是否在薪资组
                HrmSalaryPlanEmployee salaryPlanEmployee = hrmSalaryPlanEmployeeMapper.selectOne(new LambdaQueryWrapper<HrmSalaryPlanEmployee>() {{
                    eq(HrmSalaryPlanEmployee::getEmployeeId, employeeDO.getUserId());
                }});
                if (ObjectUtils.isEmpty(salaryPlanEmployee)) {
                    //不在薪资组跳过
                    throw new ResultException("存在异常人员");
                }
                SystemAttendanceTeam systemAttendanceTeam = systemAttendanceTeamMapper.selectOne(new LambdaQueryWrapper<SystemAttendanceTeam>() {{
                    like(SystemAttendanceTeam::getAdaptPerson, "%," + employeeDO.getId()+",%");
                   last("limit 1");
                }});
                if(ObjectUtils.isEmpty(systemAttendanceTeam)){
                    throw new ResultException("存在异常人员");
                }

                List<SystemColumnValue> allColumnValues = systemColumnValueMapper.selectList(new LambdaQueryWrapper<SystemColumnValue>() {{
                    like(SystemColumnValue::getDate, date);
                    eq(SystemColumnValue::getDingUserId, employeeDO.getId());
                }});
                if (ObjectUtils.isEmpty(allColumnValues)) {
                    throw new ResultException("存在异常人员");
                }
                effectiveEmployeeId.add(employeeDO.getId().intValue());
            }
            if (!ObjectUtils.isEmpty(effectiveEmployeeId)) {
                HrmSalaryRecord hrmSalaryRecord = new HrmSalaryRecord();
                hrmSalaryRecord.setCreatTime(DateUtil.currentDateFormat());
                hrmSalaryRecord.setEmployeeId(loginEmployee.getId().intValue());
                hrmSalaryRecord.setTime(date);
                EmployeeDO employeeDO = employeeMapper.selectById(loginEmployee.getId().intValue());
                hrmSalaryRecord.setUserId(employeeDO.getUserId().intValue());
                hrmSalaryRecord.setDeptId(employeeDO.getDeptId().intValue());
                hrmSalaryRecord.setCreateTime(LocalDateTime.now());
                hrmSalaryRecord.setUpdateTime(LocalDateTime.now());
                hrmSalaryRecord.setCreator("todo");
                hrmSalaryRecord.setUpdater("todo");
                hrmSalaryRecordMapper.insert(hrmSalaryRecord);
                effectiveEmployeeId.forEach(e -> {
                    getSystemAllSalaryAmount(date, e, hrmSalaryRecord, loginEmployee.getId().intValue());
                });
            }
        }else {
            if (type == 1) {
                employeeId = employeeMapper.selectList().stream().map(e -> e.getId().intValue()).collect(Collectors.toList());
            }
            List<Integer> effectiveEmployeeId = new ArrayList<>();
            Long loginId = SecurityFrameworkUtils.getLoginUserId();
            EmployeeDO loginEmployee = employeeMapper.selectOne(new LambdaQueryWrapper<EmployeeDO>() {{
                eq(EmployeeDO::getUserId, loginId);
            }});
            String createData = DateUtil.formatDateByYear(date);
            Long l1 = hrmSalaryRecordMapper.selectCount(new LambdaQueryWrapper<HrmSalaryRecord>() {{
                eq(HrmSalaryRecord::getEmployeeId, loginId);
                eq(HrmSalaryRecord::getCreatTime, createData);
            }});
            if (l1 > 0) {
                throw new ResultException(date + "工资数据已存在");
            }
            if (ObjectUtils.isEmpty(loginEmployee)) {
                throw new ResultException("当前登录账号不可以创建生成薪资");
            }
            for (int i = 0; i < employeeId.size(); i++) {
                //查看当前生成薪资人员是否存在
                EmployeeDO employeeDO = employeeMapper.selectByUserId(employeeId.get(i).longValue());
                if (ObjectUtils.isEmpty(employeeDO)) {
                    throw new ResultException("当前生成薪资人员不存在");
                    //不存在则跳过
//                continue;
                }
                Long l = hrmSalaryFixedMapper.selectCount(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
                }});
                if (l <= 0) {
                    throw new ResultException("存在异常人员");
                }
                //查看生成薪资人员是否在薪资组
                HrmSalaryPlanEmployee salaryPlanEmployee = hrmSalaryPlanEmployeeMapper.selectOne(new LambdaQueryWrapper<HrmSalaryPlanEmployee>() {{
                    eq(HrmSalaryPlanEmployee::getEmployeeId, employeeDO.getUserId());
                }});
                if (ObjectUtils.isEmpty(salaryPlanEmployee)) {
                    //不在薪资组跳过
                    throw new ResultException("存在异常人员");
                }
                if (ObjectUtils.isEmpty(employeeDO.getDingUserId())) {
                    throw new ResultException("存在异常人员");
                }
                DingUser dingUser = dingUserMapper.selectById(employeeDO.getDingUserId());
                if (ObjectUtils.isEmpty(dingUser) || ObjectUtils.isEmpty(dingUser.getTeamId())) {
                    throw new ResultException("存在异常人员");
                }
                DingColumn cdDingColumn = dingColumnMapper.selectOne(new LambdaQueryWrapper<DingColumn>() {{
                    eq(DingColumn::getAlias, "plan_detail");
                    eq(DingColumn::getTenantId, employeeDO.getTenantId());
                    last("limit 1");
                }});
                List<DingColumnValue> allColumnValues = dingColumnValueMapper.selectList(new LambdaQueryWrapper<DingColumnValue>() {{
                    ge(DingColumnValue::getDate, date + "-01" + " 00:00:00");
                    lt(DingColumnValue::getDate, date + "-31" + " 00:00:00");
                    eq(DingColumnValue::getDingUserId, employeeDO.getDingUserId());
                }});
                if (ObjectUtils.isEmpty(allColumnValues)) {
                    throw new ResultException("存在异常人员");
                }
                List<DingColumnValue> collect = allColumnValues.stream().filter(d -> d.getColumnId() == cdDingColumn.getId()).collect(Collectors.toList());
                List<DingColumnValue> collect1 = collect.stream().filter(c ->!ObjectUtils.isEmpty(c.getColumnValue()) &&c.getColumnValue().equals("-1")).collect(Collectors.toList());
//            if (!ObjectUtils.isEmpty(collect1)) {
//                throw new ResultException("存在异常人员");
//            }
                effectiveEmployeeId.add(employeeDO.getId().intValue());
            }
            if (!ObjectUtils.isEmpty(effectiveEmployeeId)) {
                HrmSalaryRecord hrmSalaryRecord = new HrmSalaryRecord();
                hrmSalaryRecord.setCreatTime(DateUtil.currentDateFormat());
                hrmSalaryRecord.setEmployeeId(loginEmployee.getId().intValue());
                hrmSalaryRecord.setTime(date);
                EmployeeDO employeeDO = employeeMapper.selectById(loginEmployee.getId().intValue());
                hrmSalaryRecord.setUserId(employeeDO.getUserId().intValue());
                hrmSalaryRecord.setDeptId(employeeDO.getDeptId().intValue());
                hrmSalaryRecord.setCreateTime(LocalDateTime.now());
                hrmSalaryRecord.setUpdateTime(LocalDateTime.now());
                hrmSalaryRecord.setCreator("todo");
                hrmSalaryRecord.setUpdater("todo");
                hrmSalaryRecordMapper.insert(hrmSalaryRecord);
                effectiveEmployeeId.forEach(e -> {
                    getAllSalaryAmount(date, e, hrmSalaryRecord, loginEmployee.getId().intValue());
                });
            }
        }

    }



    public BigDecimal getAllSalaryAmount(String workDateFrame, Integer employeeId, HrmSalaryRecord hrmSalaryRecord, Integer loginEmployeeId) {
        BigDecimal grgjj = BigDecimal.ZERO;
        BigDecimal grsb = BigDecimal.ZERO;
        EmployeeDO employeeDO = employeeMapper.selectById(employeeId);
        HrmSalaryPlanEmployee salaryPlanEmployee = hrmSalaryPlanEmployeeMapper.selectOne(new LambdaQueryWrapper<HrmSalaryPlanEmployee>() {{
            eq(HrmSalaryPlanEmployee::getEmployeeId, employeeDO.getUserId().intValue());
        }});
        CommonResult<List<DictDataRespDTO>> hrmEmployeeStatus = dictDataApi.getDictDataList("hrm_employee_status");
        CommonResult<List<DictDataRespDTO>> hrmEmploymentForm = dictDataApi.getDictDataList("hrm_employment_form");
        List<DictDataRespDTO> dictDataRespDTOS = hrmEmployeeStatus.getData();
        List<String> collect = dictDataRespDTOS.stream().filter(d -> d.getValue().equals(employeeDO.getState() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
        List<DictDataRespDTO> dictForm = hrmEmploymentForm.getCheckedData();
        List<String> collect1 = dictForm.stream().filter(d -> d.getValue().equals(employeeDO.getEmploymentForm() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
        HrmSalaryRecordEmployee hrmSalaryRecordEmployee = new HrmSalaryRecordEmployee();
        hrmSalaryRecordEmployee.setRecordId(hrmSalaryRecord.getId());
        hrmSalaryRecordEmployee.setEmployeeId(employeeId);
        hrmSalaryRecordEmployee.setEmployeeName(employeeDO.getName());
        hrmSalaryRecordEmployee.setEmployeeNo(employeeDO.getEmployeeNo());
        hrmSalaryRecordEmployee.setDepartmentId(employeeDO.getDeptId().intValue());
        hrmSalaryRecordEmployee.setPostId(employeeDO.getPostId().intValue());
        hrmSalaryRecordEmployee.setCreateTime(DateUtil.currentDateFormat());
        hrmSalaryRecordEmployee.setCreateBy(loginEmployeeId);
        hrmSalaryRecordEmployeeMapper.insert(hrmSalaryRecordEmployee);
        //社保公积金
        HrmSalarySetting salarySetting = hrmSalarySettingMapper.selectOne(new LambdaQueryWrapper<HrmSalarySetting>() {{
            last("limit 1");
        }});
        if (salarySetting.getType() == 1) {
            LocalDate localDate = LocalDate.parse(workDateFrame + "-01", DateTimeFormatter.ISO_LOCAL_DATE);
            LocalDate previousMonth = localDate.minusMonths(1);
            String previousMonthStr = previousMonth.format(DateTimeFormatter.ofPattern("yyyy-MM"));
            JSONObject jsonObject = hrmProgrammeService.generateRecord(employeeId, previousMonthStr);
            grgjj = jsonObject.getBigDecimal("gJJGRHj");
            grsb = jsonObject.getBigDecimal("sBGRHj");
        } else if (salarySetting.getType() == 2) {
            LocalDate localDate = LocalDate.parse(workDateFrame + "-01", DateTimeFormatter.ISO_LOCAL_DATE);
            String previousMonthStr = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM"));
            JSONObject jsonObject = hrmProgrammeService.generateRecord(employeeId, previousMonthStr);
            grgjj = jsonObject.getBigDecimal("gJJGRHj");
            grsb = jsonObject.getBigDecimal("sBGRHj");
        }
        HrmSalaryPlan hrmSalaryPlan = hrmSalaryPlanMapper.selectById(salaryPlanEmployee.getPlanId());
        BigDecimal sfAmount = BigDecimal.ZERO;
        BigDecimal yfAmount = BigDecimal.ZERO;
        BigDecimal kgAmount = BigDecimal.ZERO;
        BigDecimal cdAmount = BigDecimal.ZERO;
        BigDecimal ztAmount = BigDecimal.ZERO;
        BigDecimal qjAmount = BigDecimal.ZERO;
        BigDecimal sbAmount = BigDecimal.ZERO;
        BigDecimal gjjAmount = BigDecimal.ZERO;
        BigDecimal qkAmount = BigDecimal.ZERO;
        String zxDate = workDateFrame + "-15";
        Long regularizationTimeLong = employeeDO.getRegularizationTime() != null ? employeeDO.getRegularizationTime().atZone(ZoneOffset.UTC).toInstant().toEpochMilli() : 0L;
        LocalDate date = LocalDate.parse(workDateFrame + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        // 获取该月的开始日
        Long startOfMonth = date.with(TemporalAdjusters.firstDayOfMonth()).atStartOfDay().atZone(ZoneOffset.UTC).toInstant().toEpochMilli();
        // 获取该月的结束日
        Long endOfMonth = date.with(TemporalAdjusters.lastDayOfMonth()).atStartOfDay().atZone(ZoneOffset.UTC).toInstant().toEpochMilli();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        String regularizationTime = employeeDO.getRegularizationTime() != null ? employeeDO.getRegularizationTime().format(formatter) : "";
        String format = date.format(formatter);
        String monthFirst = DateUtil.monthFirstDay(format);
        String monthEnd = DateUtil.monthEndDay(format);
        DingUser dingUser = dingUserMapper.selectById(employeeDO.getDingUserId());
        System.err.println(dingUser.toString() + "dinguser");
        DingAttendanceTeam dingAttendanceTeam = dingAttendanceTeamMapper.selectById(dingUser.getTeamId());
        //整月考勤用于计算旷工、迟到、缺卡 等
        List<DingColumnValue> allColumnValues = dingColumnValueMapper.selectList(new LambdaQueryWrapper<DingColumnValue>() {{
            ge(DingColumnValue::getDate, monthFirst + " 00:00:00");
            lt(DingColumnValue::getDate, monthEnd + " 00:00:00");
            eq(DingColumnValue::getDingUserId, employeeDO.getDingUserId());
        }});
        //计算迟到扣款 迟到次数
        if (dingAttendanceTeam.getLateRulesType() == 1) {
            DingColumn cdDingColumn = dingColumnMapper.selectOne(new LambdaQueryWrapper<DingColumn>() {{
                eq(DingColumn::getAlias, "late_minute");
                eq(DingColumn::getTenantId, employeeDO.getTenantId());
                last("limit 1");
            }});
            Double lateTimeMinutes = allColumnValues.stream().filter(d -> d.getColumnId() == cdDingColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
            if (lateTimeMinutes != 0) {
                //按照迟到分钟数扣款
                BigDecimal kkMinute = new BigDecimal(lateTimeMinutes).divide(new BigDecimal(dingAttendanceTeam.getLateMinute()), 0, RoundingMode.DOWN);
                cdAmount = cdAmount.add(new BigDecimal(dingAttendanceTeam.getLateAmount()).multiply(kkMinute));
            }
        } else if (dingAttendanceTeam.getLateRulesType() == 2) {
            DingColumn cdDingColumn = dingColumnMapper.selectOne(new LambdaQueryWrapper<DingColumn>() {{
                eq(DingColumn::getAlias, "late_times");
                eq(DingColumn::getTenantId, employeeDO.getTenantId());
                last("limit 1");
            }});
            //迟到次数
            Double lateTimeDays = allColumnValues.stream().filter(d -> d.getColumnId() == cdDingColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
            if (lateTimeDays != 0) {
                BigDecimal kkMinute = new BigDecimal(lateTimeDays).divide(new BigDecimal(dingAttendanceTeam.getLateMinute()), 0, RoundingMode.DOWN);
                cdAmount = cdAmount.add(new BigDecimal(dingAttendanceTeam.getLateAmount()).multiply(kkMinute));
            }
        } else {
            DingColumn cdDingColumn = dingColumnMapper.selectOne(new LambdaQueryWrapper<DingColumn>() {{
                eq(DingColumn::getAlias, "late_times");
                eq(DingColumn::getTenantId, employeeDO.getTenantId());
                last("limit 1");
            }});
            //迟到次数
            Double lateTimeDays = allColumnValues.stream().filter(d -> d.getColumnId() == cdDingColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
            if (lateTimeDays > 0) {
                cdAmount = new BigDecimal(dingAttendanceTeam.getLateAmount());
            }
        }
        //计算早退扣款
        if (dingAttendanceTeam.getLeaveEarlyRulesType() == 1) {
            DingColumn cdDingColumn = dingColumnMapper.selectOne(new LambdaQueryWrapper<DingColumn>() {{
                eq(DingColumn::getAlias, "leave_early_minute");
                eq(DingColumn::getTenantId, employeeDO.getTenantId());
                last("limit 1");
            }});
            Double leaveEarlyMinutes = allColumnValues.stream().filter(d -> d.getColumnId() == cdDingColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
            //按照早退分钟数扣款
            if (leaveEarlyMinutes != 0) {
                BigDecimal kkMinute = new BigDecimal(leaveEarlyMinutes).divide(new BigDecimal(dingAttendanceTeam.getLeaveEarlyMinute()), 0, RoundingMode.DOWN);
                ztAmount = ztAmount.add(new BigDecimal(dingAttendanceTeam.getLeaveEarlyAmount()).multiply(kkMinute));
            }
        } else if (dingAttendanceTeam.getLeaveEarlyRulesType() == 2) {
            DingColumn cdDingColumn = dingColumnMapper.selectOne(new LambdaQueryWrapper<DingColumn>() {{
                eq(DingColumn::getAlias, "leave_early_times");
                eq(DingColumn::getTenantId, employeeDO.getTenantId());
                last("limit 1");
            }});
            Double leaveEarlyMinutes = allColumnValues.stream().filter(d -> d.getColumnId() == cdDingColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
            if (leaveEarlyMinutes > 0) {
                //按照早退次数数扣款
                BigDecimal kkMinute = new BigDecimal(leaveEarlyMinutes).divide(new BigDecimal(dingAttendanceTeam.getLeaveEarlyMinute()));
                ztAmount = ztAmount.add(new BigDecimal(dingAttendanceTeam.getLeaveEarlyAmount()).multiply(kkMinute));
            }
        } else {
            DingColumn cdDingColumn = dingColumnMapper.selectOne(new LambdaQueryWrapper<DingColumn>() {{
                eq(DingColumn::getAlias, "leave_early_times");
                eq(DingColumn::getTenantId, employeeDO.getTenantId());
                last("limit 1");
            }});
            Double leaveEarlyMinutes = allColumnValues.stream().filter(d -> d.getColumnId() == cdDingColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
            if (leaveEarlyMinutes > 0) {
                //按照早退次数数扣款
                BigDecimal kkMinute = new BigDecimal(leaveEarlyMinutes).divide(new BigDecimal(dingAttendanceTeam.getLeaveEarlyMinute()));
                ztAmount = ztAmount.add(new BigDecimal(dingAttendanceTeam.getLeaveEarlyAmount()).multiply(kkMinute));
            }
        }
        DingColumn qkSbDingColumn = dingColumnMapper.selectOne(new LambdaQueryWrapper<DingColumn>() {{
            eq(DingColumn::getAlias, "off_work_lack_card_times");
            eq(DingColumn::getTenantId, employeeDO.getTenantId());
            last("limit 1");
        }});
        DingColumn qkXbDingColumn = dingColumnMapper.selectOne(new LambdaQueryWrapper<DingColumn>() {{
            eq(DingColumn::getAlias, "off_work_lack_card_times");
            eq(DingColumn::getTenantId, employeeDO.getTenantId());
            last("limit 1");
        }});

        Double qkSbCount = allColumnValues.stream().filter(d -> d.getColumnId() == qkSbDingColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
        Double qkXbCount = allColumnValues.stream().filter(d -> d.getColumnId() == qkXbDingColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
        qkAmount = new BigDecimal(qkSbCount + qkXbCount).multiply(new BigDecimal(dingAttendanceTeam.getMissingCardNum()));
        //工资表展示基本工资 根据不同情况下面会有变更
        HrmSalaryFixed hrmShowFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
            eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
            eq(HrmSalaryFixed::getIsEffect, 1);
            orderByDesc(HrmSalaryFixed::getDate);
            last("limit 1");
        }});
        DingColumn answerRequiredColumn = dingColumnMapper.selectOne(new LambdaQueryWrapper<DingColumn>() {{
            eq(DingColumn::getAlias, "should_attendance_days");
            eq(DingColumn::getTenantId, employeeDO.getTenantId());
        }});
        DingColumn attendanceRequiredColumn = dingColumnMapper.selectOne(new LambdaQueryWrapper<DingColumn>() {{
            eq(DingColumn::getAlias, "attendance_days");
            eq(DingColumn::getTenantId, employeeDO.getTenantId());
        }});
        //本月考勤
        List<DingColumnValue> dingColumnValues = dingColumnValueMapper.selectList(new LambdaQueryWrapper<DingColumnValue>() {{
            ge(DingColumnValue::getDate, monthFirst + " 00:00:00");
            lt(DingColumnValue::getDate, monthEnd + " 23:59:59");
            eq(DingColumnValue::getDingUserId, employeeDO.getDingUserId());
        }});
        //应出勤
        Double formalPeriodAnswerRequired2 = dingColumnValues.stream().filter(d -> d.getColumnId() == answerRequiredColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
//        //实际出勤
//        Integer formalPeriodAttendanceRequired2 = dingColumnValues.stream().filter(d -> d.getColumnId() == attendanceRequiredColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
        //计算旷工
        DingColumn zzKgColumn = dingColumnMapper.selectOne(new LambdaQueryWrapper<DingColumn>() {{
            eq(DingColumn::getAlias, "absenteeism_days");
            eq(DingColumn::getTenantId, employeeDO.getTenantId());
        }});
        Double kgDays = dingColumnValues.stream().filter(d -> d.getColumnId() == zzKgColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
        if (employeeDO.getState() == 3 && regularizationTimeLong >= startOfMonth && regularizationTimeLong <= endOfMonth) {
            switch (hrmSalaryPlan.getMonthlySalaryStandard()) {
                case 1:
                    switch (hrmSalaryPlan.getSalaryAdjustmentRules()) {
                        case 1:
                            HrmSalaryFixed finalHrmShowFixed = hrmShowFixed;
                            List<HrmSalaryFixedTable> hrmShowSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                eq(HrmSalaryFixedTable::getFixedId, finalHrmShowFixed.getId());
                            }});
                            for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmShowSalaryFixedTableList) {
                                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                                hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                                hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                                hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
                                hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                                hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                            }
                            //试用期前的考勤
                            List<DingColumnValue> trialPeriodDingColumnValues = dingColumnValueMapper.selectList(new LambdaQueryWrapper<DingColumnValue>() {{
                                ge(DingColumnValue::getDate, monthFirst + " 00:00:00");
                                lt(DingColumnValue::getDate, regularizationTime + " 00:00:00");
                                eq(DingColumnValue::getDingUserId, employeeDO.getDingUserId());
                            }});
                            //转正后的考勤
                            List<DingColumnValue> formalDingColumnValues = dingColumnValueMapper.selectList(new LambdaQueryWrapper<DingColumnValue>() {{
                                ge(DingColumnValue::getDate, regularizationTime + " 00:00:00");
                                le(DingColumnValue::getDate, monthEnd + " 00:00:00");
                                eq(DingColumnValue::getDingUserId, employeeDO.getDingUserId());
                            }});

                            //试用期薪资
                            HrmSalaryFixed hrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                                eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
                                le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                                eq(HrmSalaryFixed::getIsEffect, 1);
                                orderByDesc(HrmSalaryFixed::getDate);
                                last("limit 1");
                            }});
                            //计算薪资合计
                            //试用期应出勤
                            Double trialPeriodAnswerRequired = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == answerRequiredColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
                            List<HrmSalaryFixedTable> hrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed.getId());
                            }});
                            //基本项工资
                            BigDecimal syqAmount = BigDecimal.ZERO;
                            BigDecimal syJbAmount = BigDecimal.ZERO;
                            for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTableList) {
                                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                                    continue;
                                }
                                syJbAmount = syJbAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
                            }
                            //如果试用期应出勤是0那就试用期工资为0  否则就计算基础工资/整月应出勤天数*试用期应出勤天数（旷工事假考勤扣款另扣这里只计算基础薪资）
                            if (trialPeriodAnswerRequired == 0) {

                            } else {
                                //试用期工资
                                syqAmount = syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(trialPeriodAnswerRequired));
                                List<DingColumn> dingColumns = dingColumnMapper.selectList(new LambdaQueryWrapper<DingColumn>() {{
                                    isNotNull(DingColumn::getGenceId);
                                    eq(DingColumn::getTenantId, employeeDO.getTenantId());
                                }});
                                for (DingColumn dingColumn : dingColumns) {
                                    //来区分通过 天还是小时请的假
                                    List<DingColumnValue> collect2 = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).collect(Collectors.toList());
                                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    Long count = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).count();
                                    //计算每个小时薪资是多少
                                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
                                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
                                        last("limit 1");
                                    }});
                                    if (ObjectUtils.isEmpty(dingClassTeam)) {

                                        continue;
                                    }
                                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
                                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
                                    }});
                                    //当前班次每天上多久班
                                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                                    vacationHour = vacationHour.add(bigDecimal.multiply(vacationDay));
                                    //时薪是多少
                                    BigDecimal hoursAmount = syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP).divide(bigDecimal, 2, RoundingMode.HALF_UP);
                                    DingFalseDiligence dingFalseDiligence = dingFalseDiligenceMapper.selectById(dingColumn.getGenceId());
                                    switch (dingFalseDiligence.getLeaveRulesType()) {
                                        case 1:
                                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                                            break;
                                        case 2:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP)).multiply(vacationHour));
                                            break;
                                        case 3:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                                            break;
                                    }
                                }
                            }
                            //todo 计算请假的扣款
                            //计算试用期旷工
                            DingColumn kgColumn = dingColumnMapper.selectOne(new LambdaQueryWrapper<DingColumn>() {{
                                eq(DingColumn::getAlias, "absenteeism_days");
                                eq(DingColumn::getTenantId, employeeDO.getTenantId());
                            }});
                            Double hgDays = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == kgColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();

                            if (hgDays != 0) {
                                if (dingAttendanceTeam.getAbsenteeRulesType() == 1) {
                                    //按照旷工次数扣款
                                    kgAmount = kgAmount.add(syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP)).multiply(new BigDecimal(hgDays));
                                } else {
                                    kgAmount = kgAmount.add(new BigDecimal(hgDays).multiply(new BigDecimal(dingAttendanceTeam.getAbsenteeAmount())));
                                    //按照基本工资的百分比扣款

                                }
                            }
                            //===========================转正后=====================================================================================================================================
                            //转正后的薪资
                            HrmSalaryFixed zzHrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                                eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
                                eq(HrmSalaryFixed::getIsEffect, 1);
                                orderByDesc(HrmSalaryFixed::getDate);
                                last("limit 1");
                            }});
                            List<HrmSalaryFixedTable> zzHrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                eq(HrmSalaryFixedTable::getFixedId, zzHrmSalaryFixed.getId());
                            }});
                            //应出勤
                            Double formalPeriodAnswerRequired = formalDingColumnValues.stream().filter(d -> d.getColumnId() == answerRequiredColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
                            //基本项工资
                            BigDecimal zzAmount = BigDecimal.ZERO;
                            BigDecimal zzJbAmount = BigDecimal.ZERO;
                            for (HrmSalaryFixedTable hrmSalaryFixedTable : zzHrmSalaryFixedTableList) {
                                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                                    continue;
                                }
                                zzJbAmount = zzJbAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                            }

                            //如果应出勤是0那就全额工资 否则就计算基础工资/应出勤天数*实际出勤天数
                            if (trialPeriodAnswerRequired == 0) {
                            } else {
                                //按照上班天数计算转正后的薪资
                                zzAmount = zzJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(formalPeriodAnswerRequired));
                                List<DingColumn> dingColumns = dingColumnMapper.selectList(new LambdaQueryWrapper<DingColumn>() {{
                                    isNotNull(DingColumn::getGenceId);
                                    eq(DingColumn::getTenantId, employeeDO.getTenantId());
                                }});
                                for (DingColumn dingColumn : dingColumns) {
                                    //来区分通过 天还是小时请的假
                                    List<DingColumnValue> collect2 = formalDingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).collect(Collectors.toList());
                                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    Long count = formalDingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).count();
                                    //计算每个小时薪资是多少
                                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
                                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
                                        last("limit 1");
                                    }});
                                    if (ObjectUtils.isEmpty(dingClassTeam)) {
                                        continue;
                                    }
                                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
                                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
                                    }});
                                    //当前班次每天上多久班
                                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                                    vacationHour = vacationHour.add(bigDecimal.multiply(vacationDay));
                                    //时薪是多少
                                    BigDecimal hoursAmount = zzJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP).divide(bigDecimal, 2, RoundingMode.HALF_UP);
                                    DingFalseDiligence dingFalseDiligence = dingFalseDiligenceMapper.selectById(dingColumn.getGenceId());
                                    switch (dingFalseDiligence.getLeaveRulesType()) {
                                        case 1:
                                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                                            break;
                                        case 2:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                                            break;
                                        case 3:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                                            break;
                                    }
                                }
                            }

                            Double zzHgDays = formalDingColumnValues.stream().filter(d -> d.getColumnId() == zzKgColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
                            if (zzHgDays != 0) {
                                if (dingAttendanceTeam.getAbsenteeRulesType() == 1) {
                                    //按照旷工次数扣款
                                    kgAmount = kgAmount.add(zzJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP)).multiply(new BigDecimal(zzHgDays));
                                } else {
                                    kgAmount = kgAmount.add(new BigDecimal(zzHgDays).multiply(new BigDecimal(dingAttendanceTeam.getAbsenteeAmount())));
                                    //按照基本工资的百分比扣款

                                }
                            }
                            //计算总工资
                            sfAmount = sfAmount.add(syqAmount).add(zzAmount).subtract(kgAmount);
                            yfAmount = yfAmount.add(syqAmount).add(zzAmount).subtract(kgAmount);
                            break;
                        case 2:
                            //整月按照转正薪资算
                            //转正后最后一次的调薪
                            HrmSalaryFixed zzhMonthHrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                                eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
                                eq(HrmSalaryFixed::getIsEffect, 1);
                                orderByDesc(HrmSalaryFixed::getDate);
                                last("limit 1");
                            }});
                            if (ObjectUtils.isEmpty(zzhMonthHrmSalaryFixed)) {
                                sfAmount = sfAmount.add(BigDecimal.ZERO);
                                yfAmount = yfAmount.add(BigDecimal.ZERO);
                            } else {
                                List<HrmSalaryFixedTable> zzhMonthHrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                    eq(HrmSalaryFixedTable::getFixedId, zzhMonthHrmSalaryFixed.getId());
                                }});
                                for (HrmSalaryFixedTable hrmSalaryFixedTable : zzhMonthHrmSalaryFixedTableList) {
                                    HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                    if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                                        continue;
                                    }
                                    HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                                    hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                                    hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
                                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                                    hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                                    hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                                    sfAmount = sfAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                                    yfAmount = yfAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                                }
                            }

                            if (kgDays != 0) {
                                if (dingAttendanceTeam.getAbsenteeRulesType() == 1) {
                                    //按照旷工次数扣款
                                    kgAmount = kgAmount.add(sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(kgDays)));
                                } else {
                                    kgAmount = kgAmount.add(new BigDecimal(kgDays).multiply(new BigDecimal(dingAttendanceTeam.getAbsenteeAmount())));
                                    //按照基本工资的百分比扣款

                                }
                            }
                            List<DingColumn> dingColumns = dingColumnMapper.selectList(new LambdaQueryWrapper<DingColumn>() {{
                                isNotNull(DingColumn::getGenceId);
                                eq(DingColumn::getTenantId, employeeDO.getTenantId());
                            }});
                            for (DingColumn dingColumn : dingColumns) {
                                //来区分通过 天还是小时请的假
                                List<DingColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).collect(Collectors.toList());
                                BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).count();
                                //计算每个小时薪资是多少
                                DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
                                    eq(DingClassTeam::getTeamId, dingUser.getTeamId());
                                    last("limit 1");
                                }});
                                if (ObjectUtils.isEmpty(dingClassTeam)) {

                                    continue;
                                }
                                DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
                                    eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
                                }});
                                //当前班次每天上多久班
                                BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                                vacationHour = vacationHour.add(bigDecimal.multiply(vacationDay));
                                //时薪是多少
                                BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP).divide(bigDecimal, 2, RoundingMode.HALF_UP);
                                DingFalseDiligence dingFalseDiligence = dingFalseDiligenceMapper.selectById(dingColumn.getGenceId());
                                switch (dingFalseDiligence.getLeaveRulesType()) {
                                    case 1:
                                        qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                                        break;
                                    case 2:
                                        qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                                        break;
                                    case 3:
                                        qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                                        break;
                                }
                            }
//                            yfAmount = yfAmount.subtract(kgAmount);
//                            sfAmount = sfAmount.subtract(kgAmount);

                            break;
                        case 3:
                            //判断是不是15号前转正
                            Long l = DateUtil.strZLong(zxDate + " 23:59:59");
                            if (regularizationTimeLong > l) {
                                //十五号后转正
                                //转正前最后一次的调薪
                                HrmSalaryFixed zzqHrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
                                    le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                                    eq(HrmSalaryFixed::getIsEffect, 1);
                                    orderByDesc(HrmSalaryFixed::getDate);
                                    last("limit 1");
                                }});
                                if (ObjectUtils.isEmpty(zzqHrmSalaryFixed)) {
                                    sfAmount = sfAmount.add(BigDecimal.ZERO);
                                    yfAmount = yfAmount.add(BigDecimal.ZERO);
                                } else {
                                    List<HrmSalaryFixedTable> zzqhrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                        eq(HrmSalaryFixedTable::getFixedId, zzqHrmSalaryFixed.getId());
                                    }});
                                    for (HrmSalaryFixedTable hrmSalaryFixedTable : zzqhrmSalaryFixedTableList) {
                                        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                        if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                                            continue;
                                        }
                                        HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                                        hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                                        hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
                                        hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                                        hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                                        hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                                        sfAmount = sfAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
                                        yfAmount = yfAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
                                    }
                                }
//                                if (formalPeriodAnswerRequired2 != formalPeriodAttendanceRequired2) {
//                                    if (sfAmount.compareTo(BigDecimal.ZERO) != 0) {
//                                        sfAmount = sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                        yfAmount = yfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                    }
//                                }
                                if (kgDays != 0) {
                                    if (dingAttendanceTeam.getAbsenteeRulesType() == 1) {
                                        //按照旷工次数扣款
                                        kgAmount = kgAmount.add(sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(kgDays)));
                                    } else {
                                        kgAmount = kgAmount.add(new BigDecimal(kgDays).multiply(new BigDecimal(dingAttendanceTeam.getAbsenteeAmount())));
                                        //按照基本工资的百分比扣款

                                    }
                                }
                                dingColumns = dingColumnMapper.selectList(new LambdaQueryWrapper<DingColumn>() {{
                                    isNotNull(DingColumn::getGenceId);
                                    eq(DingColumn::getTenantId, employeeDO.getTenantId());
                                }});
                                for (DingColumn dingColumn : dingColumns) {
                                    //来区分通过 天还是小时请的假
                                    List<DingColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).collect(Collectors.toList());
                                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).count();
                                    //计算每个小时薪资是多少
                                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
                                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
                                        last("limit 1");
                                    }});
                                    if (ObjectUtils.isEmpty(dingClassTeam)) {

                                        continue;
                                    }
                                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
                                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
                                    }});
                                    //当前班次每天上多久班
                                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                                    vacationHour = vacationHour.add(bigDecimal.multiply(vacationDay));
                                    //时薪是多少
                                    BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP).divide(bigDecimal, 2, RoundingMode.HALF_UP);
                                    DingFalseDiligence dingFalseDiligence = dingFalseDiligenceMapper.selectById(dingColumn.getGenceId());
                                    switch (dingFalseDiligence.getLeaveRulesType()) {
                                        case 1:
                                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                                            break;
                                        case 2:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                                            break;
                                        case 3:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                                            break;
                                    }
                                }
//                                yfAmount = yfAmount.subtract(kgAmount);
//                                sfAmount = sfAmount.subtract(kgAmount);
                            } else {
                                //十五号及十五号前转正
                                //转正后最后一次的调薪
                                HrmSalaryFixed zzhHrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
//                                    le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                                    eq(HrmSalaryFixed::getIsEffect, 1);
                                    orderByDesc(HrmSalaryFixed::getDate);
                                    last("limit 1");
                                }});
                                if (ObjectUtils.isEmpty(zzhHrmSalaryFixed)) {
                                    sfAmount = sfAmount.add(BigDecimal.ZERO);
                                    yfAmount = yfAmount.add(BigDecimal.ZERO);
                                } else {
                                    List<HrmSalaryFixedTable> zzhhrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                        eq(HrmSalaryFixedTable::getFixedId, zzhHrmSalaryFixed.getId());
                                    }});
                                    for (HrmSalaryFixedTable hrmSalaryFixedTable : zzhhrmSalaryFixedTableList) {
                                        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                        if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                                            continue;
                                        }
                                        HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                                        hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                                        hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                                        hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
                                        hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                                        hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                                        sfAmount = sfAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                                        yfAmount = yfAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                                    }
                                }
//                                if (formalPeriodAnswerRequired2 != formalPeriodAttendanceRequired2) {
//                                    if (sfAmount.compareTo(BigDecimal.ZERO) != 0) {
//                                        sfAmount = sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                        yfAmount = yfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                    }
//                                }
                                if (kgDays != 0) {
                                    if (dingAttendanceTeam.getAbsenteeRulesType() == 1) {
                                        //按照旷工次数扣款
                                        kgAmount = kgAmount.add(sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(kgDays)));

                                    } else {
                                        kgAmount = kgAmount.add(new BigDecimal(kgDays).multiply(new BigDecimal(dingAttendanceTeam.getAbsenteeAmount())));
                                        //按照基本工资的百分比扣款
                                    }
                                }
//                                yfAmount = yfAmount.subtract(kgAmount);
//                                sfAmount = sfAmount.subtract(kgAmount);

                                dingColumns = dingColumnMapper.selectList(new LambdaQueryWrapper<DingColumn>() {{
                                    isNotNull(DingColumn::getGenceId);
                                    eq(DingColumn::getTenantId, employeeDO.getTenantId());
                                }});
                                for (DingColumn dingColumn : dingColumns) {
                                    //来区分通过 天还是小时请的假
                                    List<DingColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).collect(Collectors.toList());
                                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).count();
                                    //计算每个小时薪资是多少
                                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
                                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
                                        last("limit 1");
                                    }});
                                    if (ObjectUtils.isEmpty(dingClassTeam)) {

                                        continue;
                                    }
                                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
                                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
                                    }});
                                    //当前班次每天上多久班
                                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                                    vacationHour = vacationHour.add(bigDecimal.multiply(vacationDay));
                                    //时薪是多少
                                    BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP).divide(bigDecimal, 2, RoundingMode.HALF_UP);
                                    DingFalseDiligence dingFalseDiligence = dingFalseDiligenceMapper.selectById(dingColumn.getGenceId());
                                    switch (dingFalseDiligence.getLeaveRulesType()) {
                                        case 1:
                                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                                            break;
                                        case 2:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                                            break;
                                        case 3:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                                            break;
                                    }
                                }
                            }
                            break;
                    }
                    break;
                case 2:
                    switch (hrmSalaryPlan.getSalaryAdjustmentRules()) {
                        case 1:
                            HrmSalaryFixed finalHrmShowFixed = hrmShowFixed;
                            List<HrmSalaryFixedTable> hrmShowSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                eq(HrmSalaryFixedTable::getFixedId, finalHrmShowFixed.getId());
                            }});
                            for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmShowSalaryFixedTableList) {
                                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                                hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                                hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryFixedTable.getId());
                                hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
                                hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                                hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                            }
                            //试用期前的考勤
                            List<DingColumnValue> trialPeriodDingColumnValues = dingColumnValueMapper.selectList(new LambdaQueryWrapper<DingColumnValue>() {{
                                ge(DingColumnValue::getDate, monthFirst + " 00:00:00");
                                lt(DingColumnValue::getDate, regularizationTime + " 00:00:00");
                                eq(DingColumnValue::getDingUserId, employeeDO.getDingUserId());
                            }});
                            //转正后的考勤
                            List<DingColumnValue> formalDingColumnValues = dingColumnValueMapper.selectList(new LambdaQueryWrapper<DingColumnValue>() {{
                                ge(DingColumnValue::getDate, regularizationTime + " 00:00:00");
                                le(DingColumnValue::getDate, monthEnd + " 00:00:00");
                                eq(DingColumnValue::getDingUserId, employeeDO.getDingUserId());
                            }});
                            //试用期薪资
                            HrmSalaryFixed hrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                                eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
                                le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                                eq(HrmSalaryFixed::getIsEffect, 1);
                                orderByDesc(HrmSalaryFixed::getDate);
                                last("limit 1");
                            }});
                            //计算薪资合计
                            //试用期应出勤
                            Double trialPeriodAnswerRequired = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == answerRequiredColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
//                            //实际出勤
//                            Integer trialPeriodAttendanceRequired = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == attendanceRequiredColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
                            List<HrmSalaryFixedTable> hrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed.getId());
                            }});
                            //基本项工资
                            BigDecimal syqAmount = BigDecimal.ZERO;
                            BigDecimal syJbAmount = BigDecimal.ZERO;
                            for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTableList) {
                                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                                    continue;
                                }
                                syJbAmount = syJbAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
                            }
                            //如果应出勤是0那就全额工资 否则就计算基础工资/应出勤天数*试用期应出勤天数
                            if (trialPeriodAnswerRequired == 0) {
                                syqAmount = BigDecimal.ZERO;
                            } else {
                                //按照上班天数扣款
                                syqAmount = syJbAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(trialPeriodAnswerRequired));
                                List<DingColumn> dingColumns = dingColumnMapper.selectList(new LambdaQueryWrapper<DingColumn>() {{
                                    isNotNull(DingColumn::getGenceId);
                                    eq(DingColumn::getTenantId, employeeDO.getTenantId());
                                }});
                                for (DingColumn dingColumn : dingColumns) {
                                    //来区分通过 天还是小时请的假
                                    List<DingColumnValue> collect2 = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).collect(Collectors.toList());
                                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    Long count = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).count();
                                    //计算每个小时薪资是多少
                                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
                                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
                                        last("limit 1");
                                    }});
                                    if (ObjectUtils.isEmpty(dingClassTeam)) {

                                        continue;
                                    }
                                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
                                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
                                    }});
                                    //当前班次每天上多久班
                                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                                    vacationHour = vacationHour.add(bigDecimal.multiply(vacationDay));
                                    //时薪是多少
                                    BigDecimal hoursAmount = syJbAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).divide(bigDecimal, 2, RoundingMode.HALF_UP);
                                    DingFalseDiligence dingFalseDiligence = dingFalseDiligenceMapper.selectById(dingColumn.getGenceId());
                                    switch (dingFalseDiligence.getLeaveRulesType()) {
                                        case 1:
                                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                                            break;
                                        case 2:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                                            break;
                                        case 3:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                                            break;
                                    }
                                }


                            }
                            //计算旷工
                            DingColumn kgColumn = dingColumnMapper.selectOne(new LambdaQueryWrapper<DingColumn>() {{
                                eq(DingColumn::getAlias, "absenteeism_days");
                                eq(DingColumn::getTenantId, employeeDO.getTenantId());
                            }});
                            Double hgDays = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == kgColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();

                            if (hgDays != 0) {
                                if (dingAttendanceTeam.getAbsenteeRulesType() == 1) {
                                    //按照旷工次数扣款

                                    kgAmount = kgAmount.add(syJbAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP)).multiply(new BigDecimal(hgDays));
                                } else {
                                    //按照基本工资的百分比扣款
                                    kgAmount = kgAmount.add(new BigDecimal(hgDays).multiply(new BigDecimal(dingAttendanceTeam.getAbsenteeAmount())));
                                }
                            }
                            //===========================转正后=====================================================================================================================================
                            //转正后薪资
                            HrmSalaryFixed zzHrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                                eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
                                eq(HrmSalaryFixed::getIsEffect, 1);
                                orderByDesc(HrmSalaryFixed::getDate);
                                last("limit 1");
                            }});
                            List<HrmSalaryFixedTable> zzHrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                eq(HrmSalaryFixedTable::getFixedId, zzHrmSalaryFixed.getId());
                            }});
                            //应出勤
                            Double formalPeriodAnswerRequired = formalDingColumnValues.stream().filter(d -> d.getColumnId() == answerRequiredColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
//                            //实际出勤
//                            Integer formalPeriodAttendanceRequired = formalDingColumnValues.stream().filter(d -> d.getColumnId() == attendanceRequiredColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
                            //基本项工资
                            BigDecimal zzAmount = BigDecimal.ZERO;
                            BigDecimal zzJbAmount = BigDecimal.ZERO;
                            for (HrmSalaryFixedTable hrmSalaryFixedTable : zzHrmSalaryFixedTableList) {
                                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                                    continue;
                                }
                                zzJbAmount = zzJbAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                            }
                            //如果应出勤是0那就全额工资 否则就计算基础工资/应出勤天数*实际出勤天数
                            if (trialPeriodAnswerRequired == 0) {
                            } else {
                                //按照上班天数扣款
                                zzAmount = zzJbAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(formalPeriodAnswerRequired));
                                List<DingColumn> dingColumns = dingColumnMapper.selectList(new LambdaQueryWrapper<DingColumn>() {{
                                    isNotNull(DingColumn::getGenceId);
                                    eq(DingColumn::getTenantId, employeeDO.getTenantId());
                                }});
                                for (DingColumn dingColumn : dingColumns) {
                                    //来区分通过 天还是小时请的假
                                    List<DingColumnValue> collect2 = formalDingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).collect(Collectors.toList());
                                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    Long count = formalDingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).count();
                                    //计算每个小时薪资是多少
                                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
                                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
                                        last("limit 1");
                                    }});
                                    if (ObjectUtils.isEmpty(dingClassTeam)) {
                                        continue;
                                    }
                                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
                                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
                                    }});
                                    //当前班次每天上多久班
                                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                                    vacationHour = vacationHour.add(bigDecimal.multiply(vacationDay));
                                    //时薪是多少
                                    BigDecimal hoursAmount = zzJbAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).divide(bigDecimal, 2, RoundingMode.HALF_UP);
                                    DingFalseDiligence dingFalseDiligence = dingFalseDiligenceMapper.selectById(dingColumn.getGenceId());
                                    switch (dingFalseDiligence.getLeaveRulesType()) {
                                        case 1:
                                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                                            break;
                                        case 2:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                                            break;
                                        case 3:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                                            break;
                                    }
                                }

                            }
                            Double zzHgDays = formalDingColumnValues.stream().filter(d -> d.getColumnId() == zzKgColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
                            if (zzHgDays != 0) {
                                if (dingAttendanceTeam.getAbsenteeRulesType() == 1) {
                                    //按照旷工次数扣款
                                    kgAmount = kgAmount.add(zzJbAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP)).multiply(new BigDecimal(zzHgDays));
                                } else {
                                    kgAmount = kgAmount.add(new BigDecimal(zzHgDays).multiply(new BigDecimal(dingAttendanceTeam.getAbsenteeAmount())));
                                    //按照基本工资的百分比扣款

                                }
                            }
                            //计算总工资
                            sfAmount = sfAmount.add(syqAmount).add(zzAmount).subtract(kgAmount);
                            yfAmount = yfAmount.add(syqAmount).add(zzAmount).subtract(kgAmount);
                            break;
                        case 2:
                            //整月按照转正薪资算
                            //转正后最后一次的调薪
                            HrmSalaryFixed zzhMonthHrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                                eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
                                eq(HrmSalaryFixed::getIsEffect, 1);
                                orderByDesc(HrmSalaryFixed::getDate);
                                last("limit 1");
                            }});
                            if (ObjectUtils.isEmpty(zzhMonthHrmSalaryFixed)) {
                                sfAmount = sfAmount.add(BigDecimal.ZERO);
                                yfAmount = yfAmount.add(BigDecimal.ZERO);
                            } else {
                                List<HrmSalaryFixedTable> zzhMonthHrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                    eq(HrmSalaryFixedTable::getFixedId, zzhMonthHrmSalaryFixed.getId());
                                }});
                                for (HrmSalaryFixedTable hrmSalaryFixedTable : zzhMonthHrmSalaryFixedTableList) {
                                    HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                    if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                                        continue;
                                    }
                                    HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                                    hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                                    hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
                                    hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                                    hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                                    sfAmount = sfAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                                    yfAmount = yfAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                                }
                            }
                            if (kgDays != 0) {
                                if (dingAttendanceTeam.getAbsenteeRulesType() == 1) {
                                    //按照旷工次数扣款

                                    kgAmount = kgAmount.add(sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(kgDays)));
                                } else {
                                    //按照基本工资的百分比扣款
                                    kgAmount = kgAmount.add(new BigDecimal(kgDays).multiply(new BigDecimal(dingAttendanceTeam.getAbsenteeAmount())));
                                }
                            }
                            List<DingColumn> dingColumns = dingColumnMapper.selectList(new LambdaQueryWrapper<DingColumn>() {{
                                isNotNull(DingColumn::getGenceId);
                                eq(DingColumn::getTenantId, employeeDO.getTenantId());
                            }});
                            for (DingColumn dingColumn : dingColumns) {
                                //来区分通过 天还是小时请的假
                                List<DingColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).collect(Collectors.toList());
                                BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).count();
                                //计算每个小时薪资是多少
                                DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
                                    eq(DingClassTeam::getTeamId, dingUser.getTeamId());
                                    last("limit 1");
                                }});
                                if (ObjectUtils.isEmpty(dingClassTeam)) {
                                    continue;
                                }
                                DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
                                    eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
                                }});
                                //当前班次每天上多久班
                                BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                                vacationHour = vacationHour.add(bigDecimal.multiply(vacationDay));
                                //时薪是多少
                                BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).divide(bigDecimal, 2, RoundingMode.HALF_UP);
                                DingFalseDiligence dingFalseDiligence = dingFalseDiligenceMapper.selectById(dingColumn.getGenceId());
                                switch (dingFalseDiligence.getLeaveRulesType()) {
                                    case 1:
                                        qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                                        break;
                                    case 2:
                                        qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                                        break;
                                    case 3:
                                        qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                                        break;
                                }
                            }


//                            yfAmount = yfAmount.subtract(kgAmount);
//                            sfAmount = sfAmount.subtract(kgAmount);
                            break;
                        case 3:
                            //判断是不是15号前转正
                            Long l = DateUtil.strZLong(zxDate + " 23:59:59");
                            if (regularizationTimeLong > l) {
                                //十五号后转正
                                //转正前最后一次的调薪
                                HrmSalaryFixed zzqHrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
                                    le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                                    eq(HrmSalaryFixed::getIsEffect, 1);
                                    orderByDesc(HrmSalaryFixed::getDate);
                                    last("limit 1");
                                }});
                                if (ObjectUtils.isEmpty(zzqHrmSalaryFixed)) {
                                    sfAmount = sfAmount.add(BigDecimal.ZERO);
                                    yfAmount = yfAmount.add(BigDecimal.ZERO);
                                } else {
                                    List<HrmSalaryFixedTable> zzqhrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                        eq(HrmSalaryFixedTable::getFixedId, zzqHrmSalaryFixed.getId());
                                    }});
                                    for (HrmSalaryFixedTable hrmSalaryFixedTable : zzqhrmSalaryFixedTableList) {
                                        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                        if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                                            continue;
                                        }
                                        HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                                        hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                                        hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                                        hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeFrontAmount());
                                        hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                                        hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);

                                        sfAmount = sfAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
                                        yfAmount = yfAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
                                    }
                                }
//                                if (formalPeriodAnswerRequired2 != formalPeriodAttendanceRequired2) {
//                                    if (sfAmount.compareTo(BigDecimal.ZERO) != 0) {
//                                        sfAmount = sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                        yfAmount = yfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                    }
//                                }
                                if (kgDays != 0) {
                                    if (dingAttendanceTeam.getAbsenteeRulesType() == 1) {
                                        //按照旷工次数扣款
                                        kgAmount = kgAmount.add(sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(kgDays)));
                                    } else {
                                        //按照基本工资的百分比扣款

                                        kgAmount = kgAmount.add(new BigDecimal(kgDays).multiply(new BigDecimal(dingAttendanceTeam.getAbsenteeAmount())));
                                    }
                                }
                                dingColumns = dingColumnMapper.selectList(new LambdaQueryWrapper<DingColumn>() {{
                                    isNotNull(DingColumn::getGenceId);
                                    eq(DingColumn::getTenantId, employeeDO.getTenantId());
                                }});
                                for (DingColumn dingColumn : dingColumns) {
                                    //来区分通过 天还是小时请的假
                                    List<DingColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).collect(Collectors.toList());
                                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).count();
                                    //计算每个小时薪资是多少
                                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
                                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
                                        last("limit 1");
                                    }});
                                    if (ObjectUtils.isEmpty(dingClassTeam)) {

                                        continue;
                                    }
                                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
                                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
                                    }});
                                    //当前班次每天上多久班
                                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                                    vacationHour = vacationHour.add(bigDecimal.multiply(vacationDay));
                                    //时薪是多少
                                    BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).divide(bigDecimal, 2, RoundingMode.HALF_UP);
                                    DingFalseDiligence dingFalseDiligence = dingFalseDiligenceMapper.selectById(dingColumn.getGenceId());
                                    switch (dingFalseDiligence.getLeaveRulesType()) {
                                        case 1:
                                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                                            break;
                                        case 2:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                                            break;
                                        case 3:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                                            break;
                                    }
                                }

//                                yfAmount = yfAmount.subtract(kgAmount);
//                                sfAmount = sfAmount.subtract(kgAmount);

                            } else {
                                //十五号及十五号前转正
                                //转正后最后一次的调薪
                                HrmSalaryFixed zzhHrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
//                                    le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                                    eq(HrmSalaryFixed::getIsEffect, 1);
                                    orderByDesc(HrmSalaryFixed::getDate);
                                    last("limit 1");
                                }});
                                if (ObjectUtils.isEmpty(zzhHrmSalaryFixed)) {
                                    sfAmount = sfAmount.add(BigDecimal.ZERO);
                                    yfAmount = yfAmount.add(BigDecimal.ZERO);
                                } else {
                                    List<HrmSalaryFixedTable> zzhhrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                        eq(HrmSalaryFixedTable::getFixedId, zzhHrmSalaryFixed.getId());
                                    }});
                                    for (HrmSalaryFixedTable hrmSalaryFixedTable : zzhhrmSalaryFixedTableList) {
                                        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                        if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                                            continue;
                                        }
                                        HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                                        hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                                        hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                                        hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
                                        hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                                        hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                                        sfAmount = sfAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                                        yfAmount = yfAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                                    }
                                }
//                                    if (formalPeriodAnswerRequired2 != formalPeriodAttendanceRequired2) {
//                                        if (sfAmount.compareTo(BigDecimal.ZERO) != 0) {
//                                            sfAmount = sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                            yfAmount = yfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                        }
//                                    }
                                dingColumns = dingColumnMapper.selectList(new LambdaQueryWrapper<DingColumn>() {{
                                    isNotNull(DingColumn::getGenceId);
                                    eq(DingColumn::getTenantId, employeeDO.getTenantId());
                                }});
                                for (DingColumn dingColumn : dingColumns) {
                                    //来区分通过 天还是小时请的假
                                    List<DingColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).collect(Collectors.toList());
                                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).count();
                                    //计算每个小时薪资是多少
                                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
                                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
                                        last("limit 1");
                                    }});
                                    if (ObjectUtils.isEmpty(dingClassTeam)) {

                                        continue;
                                    }
                                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
                                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
                                    }});
                                    //当前班次每天上多久班
                                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                                    vacationHour = vacationHour.add(bigDecimal.multiply(vacationDay));
                                    //时薪是多少
                                    BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).divide(bigDecimal, 2, RoundingMode.HALF_UP);
                                    DingFalseDiligence dingFalseDiligence = dingFalseDiligenceMapper.selectById(dingColumn.getGenceId());
                                    switch (dingFalseDiligence.getLeaveRulesType()) {
                                        case 1:
                                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                                            break;
                                        case 2:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                                            break;
                                        case 3:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                                            break;
                                    }
                                }
                                if (kgDays != 0) {
                                    if (dingAttendanceTeam.getAbsenteeRulesType() == 1) {
                                        //按照旷工次数扣款
                                        kgAmount = kgAmount.add(sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(kgDays)));
                                    } else {
                                        kgAmount = kgAmount.add(new BigDecimal(kgDays).multiply(new BigDecimal(dingAttendanceTeam.getAbsenteeAmount())));
                                        //按照基本工资的百分比扣款

                                    }
                                }
//                                yfAmount = yfAmount.subtract(kgAmount);
//                                sfAmount = sfAmount.subtract(kgAmount);
                            }
                            break;
                    }
                    break;
            }

        } else if (employeeDO.getRegularizationTime() == null) {
            if (hrmSalaryPlan.getMonthlySalaryStandard() == 1) {
                List<DingColumnValue> trialPeriodDingColumnValues = dingColumnValueMapper.selectList(new LambdaQueryWrapper<DingColumnValue>() {{
                    ge(DingColumnValue::getDate, monthFirst + " 00:00:00");
                    le(DingColumnValue::getDate, monthEnd + " 00:00:00");
                    eq(DingColumnValue::getDingUserId, employeeDO.getDingUserId());
                }});
                //试用期薪资
                HrmSalaryFixed hrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
//                    le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                    eq(HrmSalaryFixed::getIsEffect, 1);
                    orderByDesc(HrmSalaryFixed::getDate);
                    last("limit 1");
                }});
                //计算薪资合计
                List<HrmSalaryFixedTable> hrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                    eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed.getId());
                }});
                //基本项工资
                BigDecimal syqAmount = BigDecimal.ZERO;
                BigDecimal syJbAmount = BigDecimal.ZERO;
                for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTableList) {
                    HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                    if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                        continue;
                    }
                    HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                    hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeFrontAmount());
                    hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                    hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                    syJbAmount = syJbAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
                }

                //如果应出勤是0那就全额工资 否则就计算基础工资/应出勤天数*实际出勤天数
                if (formalPeriodAnswerRequired2 == 0) {
                    yfAmount = BigDecimal.ZERO;
                    sfAmount = BigDecimal.ZERO;
                } else {
                    //按照上班天数扣款
//                yfAmount = syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_HALF_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
                    yfAmount = syJbAmount;
//                sfAmount = syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_HALF_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
                    sfAmount = syJbAmount;
                }
                //计算旷工
                DingColumn kgColumn = dingColumnMapper.selectOne(new LambdaQueryWrapper<DingColumn>() {{
                    eq(DingColumn::getAlias, "absenteeism_days");
                    eq(DingColumn::getTenantId, employeeDO.getTenantId());
                }});
                Double hgDays = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == kgColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();

                if (hgDays != 0) {
                    if (dingAttendanceTeam.getAbsenteeRulesType() == 1) {
                        //按照旷工次数扣款
                        kgAmount = kgAmount.add(syJbAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP)).multiply(new BigDecimal(hgDays));
                    } else {
                        //按照基本工资的百分比扣款

                        kgAmount = kgAmount.add(new BigDecimal(hgDays).multiply(new BigDecimal(dingAttendanceTeam.getAbsenteeAmount())));
                    }
                }
            } else {

                List<DingColumnValue> trialPeriodDingColumnValues = dingColumnValueMapper.selectList(new LambdaQueryWrapper<DingColumnValue>() {{
                    ge(DingColumnValue::getDate, monthFirst + " 00:00:00");
                    le(DingColumnValue::getDate, monthEnd + " 00:00:00");
                    eq(DingColumnValue::getDingUserId, employeeDO.getDingUserId());
                }});
                //试用期薪资
                HrmSalaryFixed hrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
//                    le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                    eq(HrmSalaryFixed::getIsEffect, 1);
                    orderByDesc(HrmSalaryFixed::getDate);
                    last("limit 1");
                }});
                //计算薪资合计
                List<HrmSalaryFixedTable> hrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                    eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed.getId());
                }});
                //基本项工资
                BigDecimal syqAmount = BigDecimal.ZERO;
                BigDecimal syJbAmount = BigDecimal.ZERO;
                for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTableList) {
                    HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                    if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                        continue;
                    }
                    HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                    hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeFrontAmount());
                    hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                    hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                    syJbAmount = syJbAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
                }
                //如果应出勤是0那就全额工资 否则就计算基础工资/应出勤天数*实际出勤天数
                if (formalPeriodAnswerRequired2 == 0) {
                } else {
                    //按照上班天数扣款
//                yfAmount = syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_HALF_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
                    yfAmount = syJbAmount;
//                sfAmount = syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_HALF_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
                    sfAmount = syJbAmount;
                }

                List<DingColumn> dingColumns = dingColumnMapper.selectList(new LambdaQueryWrapper<DingColumn>() {{
                    isNotNull(DingColumn::getGenceId);
                    eq(DingColumn::getTenantId, employeeDO.getTenantId());
                }});
                for (DingColumn dingColumn : dingColumns) {
                    //来区分通过 天还是小时请的假
                    List<DingColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).collect(Collectors.toList());
                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                    Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).count();
                    //计算每个小时薪资是多少
                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
                        last("limit 1");
                    }});
                    if (ObjectUtils.isEmpty(dingClassTeam)) {

                        continue;
                    }
                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
                    }});
                    //当前班次每天上多久班
                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                    vacationHour = vacationHour.add(bigDecimal.multiply(vacationDay));
                    //时薪是多少
                    BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).divide(bigDecimal, 2, RoundingMode.HALF_UP);
                    DingFalseDiligence dingFalseDiligence = dingFalseDiligenceMapper.selectById(dingColumn.getGenceId());
                    switch (dingFalseDiligence.getLeaveRulesType()) {
                        case 1:
                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                            break;
                        case 2:
                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                            break;
                        case 3:
                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                            break;
                    }
                }
                //计算旷工
                DingColumn kgColumn = dingColumnMapper.selectOne(new LambdaQueryWrapper<DingColumn>() {{
                    eq(DingColumn::getAlias, "absenteeism_days");
                    eq(DingColumn::getTenantId, employeeDO.getTenantId());
                }});
                Double hgDays = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == kgColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();

                if (hgDays != 0) {
                    if (dingAttendanceTeam.getAbsenteeRulesType() == 1) {
                        //按照旷工次数扣款
                        //按照基本工资的百分比扣款
                        kgAmount = kgAmount.add(syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP)).multiply(new BigDecimal(hgDays));
                    } else {
                        kgAmount = kgAmount.add(new BigDecimal(hgDays).multiply(new BigDecimal(dingAttendanceTeam.getAbsenteeAmount())));

                    }
                }
            }

        } else {
            if (hrmSalaryPlan.getMonthlySalaryStandard() == 1) {
                List<DingColumnValue> trialPeriodDingColumnValues = dingColumnValueMapper.selectList(new LambdaQueryWrapper<DingColumnValue>() {{
                    ge(DingColumnValue::getDate, monthFirst + " 00:00:00");
                    le(DingColumnValue::getDate, monthEnd + " 00:00:00");
                    eq(DingColumnValue::getDingUserId, employeeDO.getDingUserId());
                }});
                //试用期薪资
                HrmSalaryFixed hrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
//                le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                    eq(HrmSalaryFixed::getIsEffect, 1);
                    orderByDesc(HrmSalaryFixed::getDate);
                    last("limit 1");
                }});
                //计算薪资合计
                List<HrmSalaryFixedTable> hrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                    eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed.getId());
                }});
                //基本项工资
                BigDecimal syJbAmount = BigDecimal.ZERO;
                for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTableList) {
                    HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                    if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                        continue;
                    }

                    HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                    hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
                    hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                    hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                    syJbAmount = syJbAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                }
                //如果应出勤是0那就全额工资 否则就计算基础工资/应出勤天数*实际出勤天数
                if (formalPeriodAnswerRequired2 == 0) {
                } else {
                    //按照上班天数扣款
//                yfAmount = syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_HALF_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
                    yfAmount = syJbAmount;
//                sfAmount = syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_HALF_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
                    sfAmount = syJbAmount;
                }

                List<DingColumn> dingColumns = dingColumnMapper.selectList(new LambdaQueryWrapper<DingColumn>() {{
                    isNotNull(DingColumn::getGenceId);
                    eq(DingColumn::getTenantId, employeeDO.getTenantId());
                }});
                for (DingColumn dingColumn : dingColumns) {
                    //来区分通过 天还是小时请的假
                    List<DingColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).collect(Collectors.toList());
                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                    Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).count();
                    //计算每个小时薪资是多少
                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
                        last("limit 1");
                    }});
                    if (ObjectUtils.isEmpty(dingClassTeam)) {

                        continue;
                    }
                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
                    }});
                    //当前班次每天上多久班
                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                    vacationHour = vacationHour.add(bigDecimal.multiply(vacationDay));
                    //时薪是多少
                    BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).divide(bigDecimal, 2, RoundingMode.HALF_UP);
                    DingFalseDiligence dingFalseDiligence = dingFalseDiligenceMapper.selectById(dingColumn.getGenceId());
                    switch (dingFalseDiligence.getLeaveRulesType()) {
                        case 1:
                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                            break;
                        case 2:
                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                            break;
                        case 3:
                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                            break;
                    }
                }
                //计算旷工
                DingColumn kgColumn = dingColumnMapper.selectOne(new LambdaQueryWrapper<DingColumn>() {{
                    eq(DingColumn::getAlias, "absenteeism_days");
                    eq(DingColumn::getTenantId, employeeDO.getTenantId());
                }});
                Double hgDays = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == kgColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();

                if (hgDays != 0) {
                    if (dingAttendanceTeam.getAbsenteeRulesType() == 1) {
                        //按照旷工次数扣款
                        kgAmount = kgAmount.add(syJbAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP)).multiply(new BigDecimal(hgDays));

                    } else {
                        kgAmount = kgAmount.add(new BigDecimal(hgDays).multiply(new BigDecimal(dingAttendanceTeam.getAbsenteeAmount())));
                        //按照基本工资的百分比扣款
                    }
                }
            } else {
                List<DingColumnValue> trialPeriodDingColumnValues = dingColumnValueMapper.selectList(new LambdaQueryWrapper<DingColumnValue>() {{
                    ge(DingColumnValue::getDate, monthFirst + " 00:00:00");
                    le(DingColumnValue::getDate, monthEnd + " 00:00:00");
                    eq(DingColumnValue::getDingUserId, employeeDO.getDingUserId());
                }});
                //试用期薪资
                HrmSalaryFixed hrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
//                le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                    eq(HrmSalaryFixed::getIsEffect, 1);
                    orderByDesc(HrmSalaryFixed::getDate);
                    last("limit 1");
                }});
                //计算薪资合计
                List<HrmSalaryFixedTable> hrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                    eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed.getId());
                }});
                //基本项工资
                BigDecimal syJbAmount = BigDecimal.ZERO;
                for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTableList) {
                    HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                    if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                        continue;
                    }
                    HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                    hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                    hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
                    hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                    syJbAmount = syJbAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                }
                //如果应出勤是0那就全额工资 否则就计算基础工资/应出勤天数*实际出勤天数
                if (formalPeriodAnswerRequired2 == 0) {
                } else {
                    //按照上班天数扣款
//                yfAmount = syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_HALF_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
                    yfAmount = syJbAmount;
//                sfAmount = syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_HALF_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
                    sfAmount = syJbAmount;
                }

                List<DingColumn> dingColumns = dingColumnMapper.selectList(new LambdaQueryWrapper<DingColumn>() {{
                    isNotNull(DingColumn::getGenceId);
                    eq(DingColumn::getTenantId, employeeDO.getTenantId());
                }});
                for (DingColumn dingColumn : dingColumns) {
                    //来区分通过 天还是小时请的假
                    List<DingColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).collect(Collectors.toList());
                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                    Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == dingColumn.getId()).count();
                    //计算每个小时薪资是多少
                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
                        last("limit 1");
                    }});
                    if (ObjectUtils.isEmpty(dingClassTeam)) {

                        continue;
                    }
                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
                    }});
                    //当前班次每天上多久班
                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                    vacationHour = vacationHour.add(bigDecimal.multiply(vacationDay));
                    //时薪是多少
                    BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).divide(bigDecimal, 2, RoundingMode.HALF_UP);
                    DingFalseDiligence dingFalseDiligence = dingFalseDiligenceMapper.selectById(dingColumn.getGenceId());
                    switch (dingFalseDiligence.getLeaveRulesType()) {
                        case 1:
                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                            break;
                        case 2:
                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                            break;
                        case 3:
                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                            break;
                    }
                }
                //计算旷工
                DingColumn kgColumn = dingColumnMapper.selectOne(new LambdaQueryWrapper<DingColumn>() {{
                    eq(DingColumn::getAlias, "absenteeism_days");
                    eq(DingColumn::getTenantId, employeeDO.getTenantId());
                }});
                Double hgDays = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == kgColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();

                if (hgDays != 0) {
                    if (dingAttendanceTeam.getAbsenteeRulesType() == 1) {
                        //按照基本工资的百分比扣款
                        kgAmount = kgAmount.add(syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP)).multiply(new BigDecimal(hgDays));


                    } else {
                        //按照旷工次数扣款
                        kgAmount = kgAmount.add(new BigDecimal(hgDays).multiply(new BigDecimal(dingAttendanceTeam.getAbsenteeAmount())));
                    }
                }
            }
        }
//        sfAmount = sfAmount.subtract(grsb).subtract(grgjj);
//        yfAmount = yfAmount.subtract(sbAmount).subtract(gjjAmount).subtract(cdAmount).subtract(kgAmount).subtract(ztAmount).subtract(qkAmount).subtract(qjAmount);
//        sfAmount = sfAmount.subtract(cdAmount).subtract(kgAmount).subtract(ztAmount).subtract(qkAmount).subtract(qjAmount);
        List<HrmSalaryTableConfigTenant> allHrmSalaryTableConfigTenants = hrmSalaryTableConfigTenantMapper.selectList(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
            eq(HrmSalaryTableConfigTenant::getIsDisplayed, 1);
            eq(HrmSalaryTableConfigTenant::getStatus, 1);
            ne(HrmSalaryTableConfigTenant::getPid, 0);
            orderByAsc(HrmSalaryTableConfigTenant::getDistinguish);
        }});
        Integer sfAmountId=-1;
        Integer yfAmountId=-1;
        for (int i = 0; i < allHrmSalaryTableConfigTenants.size(); i++) {
            HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(allHrmSalaryTableConfigTenants.get(i).getId());
            if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                continue;
            }
            if (hrmSalaryTableConfigTenant.getDistinguish() == 39 || hrmSalaryTableConfigTenant.getDistinguish() == 40 || hrmSalaryTableConfigTenant.getDistinguish() == 41) {
                continue;
            }
            HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
            hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
            hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
            switch (hrmSalaryTableConfigTenant.getDistinguish()) {
                //考勤扣款多少钱暂时手填预留出来
                //迟到扣款
                case 12:
                    hrmSalaryRecordEmployeeTable.setIsConfirm(1);
                    hrmSalaryRecordEmployeeTable.setValue(cdAmount);
                    sfAmount=sfAmount.subtract(cdAmount);
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    yfAmount = yfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    sfAmount=sfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    break;
                //早退扣款
                case 13:
                    hrmSalaryRecordEmployeeTable.setIsConfirm(1);
                    hrmSalaryRecordEmployeeTable.setValue(ztAmount);
                    sfAmount=sfAmount.subtract(ztAmount);
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    yfAmount = yfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    sfAmount=sfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    break;
                //旷工扣款
                case 14:
                    hrmSalaryRecordEmployeeTable.setIsConfirm(1);
                    hrmSalaryRecordEmployeeTable.setValue(kgAmount);
                    sfAmount=sfAmount.subtract(kgAmount);
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    yfAmount = yfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    sfAmount=sfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    break;
                //假期扣款
                case 15:
                    hrmSalaryRecordEmployeeTable.setIsConfirm(1);
                    hrmSalaryRecordEmployeeTable.setValue(qjAmount);
                    sfAmount=sfAmount.subtract(qjAmount);
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    yfAmount = yfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    sfAmount=sfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    break;
                //缺卡扣款
                case 16:
                    hrmSalaryRecordEmployeeTable.setIsConfirm(1);
                    hrmSalaryRecordEmployeeTable.setValue(qkAmount);
                    sfAmount=sfAmount.subtract(qkAmount);
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    yfAmount = yfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    sfAmount=sfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    break;
                //考勤扣款合计
                case 18:
                    hrmSalaryRecordEmployeeTable.setIsConfirm(1);
                    hrmSalaryRecordEmployeeTable.setValue(qkAmount.add(kgAmount).add(cdAmount).add(ztAmount).add(qjAmount));
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    break;
                case 19:
//                    hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                    hrmSalaryRecordEmployeeTable.setValue(yfAmount);
//                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    break;
                case 22:
//                    hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                    hrmSalaryRecordEmployeeTable.setValue(sfAmount);
//                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    break;
                //个人社保
                case 68:
                    hrmSalaryRecordEmployeeTable.setValue(grsb);
                    sfAmount=sfAmount.subtract(grsb);
                    hrmSalaryRecordEmployeeTable.setIsConfirm(1);
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    sfAmount=sfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    break;
                //个人公积金
                case 69:
                    sfAmount=sfAmount.subtract(grgjj);
                    hrmSalaryRecordEmployeeTable.setValue(grgjj);
                    hrmSalaryRecordEmployeeTable.setIsConfirm(1);
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    sfAmount=sfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    break;
                case 39:
                    break;
                case 40:
                    break;
                case 41:
                    break;
                default:
                    if (hrmSalaryTableConfigTenant.getIsAddSubtract() == 1) {
                        hrmSalaryRecordEmployeeTable.setIsConfirm(1);
                        hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                        if(!ObjectUtils.isEmpty(hrmSalaryRecordEmployeeTable.getValue())){
                            sfAmount = sfAmount.add(hrmSalaryRecordEmployeeTable.getValue());
                            yfAmount = yfAmount.add(hrmSalaryRecordEmployeeTable.getValue());
                        }
                    } else if (hrmSalaryTableConfigTenant.getIsAddSubtract() == 2) {
                        hrmSalaryRecordEmployeeTable.setIsConfirm(1);
                        hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());


                        if(!ObjectUtils.isEmpty(hrmSalaryRecordEmployeeTable.getValue())){
                            sfAmount = sfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                            yfAmount = yfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                        }
                    }
            }


            hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
            if (hrmSalaryTableConfigTenant.getDistinguish() == 22 ) {
                sfAmountId=hrmSalaryRecordEmployeeTable.getId();
            }
            if(hrmSalaryTableConfigTenant.getDistinguish()==19){
                yfAmountId=hrmSalaryRecordEmployeeTable.getId();
            }
        }

        if(sfAmountId!=-1){
            HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = hrmSalaryRecordEmployeeTableMapper.selectById(sfAmountId);
                      hrmSalaryRecordEmployeeTable.setIsConfirm(1);
                    hrmSalaryRecordEmployeeTable.setValue(sfAmount);
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(3);
            hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTable);

        }

        if(yfAmountId!=-1){
            HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = hrmSalaryRecordEmployeeTableMapper.selectById(yfAmountId);
            hrmSalaryRecordEmployeeTable.setIsConfirm(1);
            hrmSalaryRecordEmployeeTable.setValue(yfAmount);
            hrmSalaryRecordEmployeeTable.setIsAddSubtract(3);
            hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTable);

        }

        return null;

    }



    public BigDecimal getSystemAllSalaryAmount(String workDateFrame, Integer employeeId, HrmSalaryRecord hrmSalaryRecord, Integer loginEmployeeId)
    {

        BigDecimal grgjj = BigDecimal.ZERO;
        BigDecimal grsb = BigDecimal.ZERO;
        EmployeeDO employeeDO = employeeMapper.selectById(employeeId);
        HrmSalaryPlanEmployee salaryPlanEmployee = hrmSalaryPlanEmployeeMapper.selectOne(new LambdaQueryWrapper<HrmSalaryPlanEmployee>() {{
            eq(HrmSalaryPlanEmployee::getEmployeeId, employeeDO.getUserId().intValue());
        }});
        CommonResult<List<DictDataRespDTO>> hrmEmployeeStatus = dictDataApi.getDictDataList("hrm_employee_status");
        CommonResult<List<DictDataRespDTO>> hrmEmploymentForm = dictDataApi.getDictDataList("hrm_employment_form");
        List<DictDataRespDTO> dictDataRespDTOS = hrmEmployeeStatus.getData();
        List<String> collect = dictDataRespDTOS.stream().filter(d -> d.getValue().equals(employeeDO.getState() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
        List<DictDataRespDTO> dictForm = hrmEmploymentForm.getCheckedData();
        List<String> collect1 = dictForm.stream().filter(d -> d.getValue().equals(employeeDO.getEmploymentForm() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
        HrmSalaryRecordEmployee hrmSalaryRecordEmployee = new HrmSalaryRecordEmployee();
        hrmSalaryRecordEmployee.setRecordId(hrmSalaryRecord.getId());
        hrmSalaryRecordEmployee.setEmployeeId(employeeId);
        hrmSalaryRecordEmployee.setEmployeeName(employeeDO.getName());
        hrmSalaryRecordEmployee.setEmployeeNo(employeeDO.getEmployeeNo());
        hrmSalaryRecordEmployee.setDepartmentId(employeeDO.getDeptId().intValue());
        hrmSalaryRecordEmployee.setPostId(employeeDO.getPostId().intValue());
        hrmSalaryRecordEmployee.setCreateTime(DateUtil.currentDateFormat());
        hrmSalaryRecordEmployee.setCreateBy(loginEmployeeId);
        hrmSalaryRecordEmployeeMapper.insert(hrmSalaryRecordEmployee);
        //社保公积金
        HrmSalarySetting salarySetting = hrmSalarySettingMapper.selectOne(new LambdaQueryWrapper<HrmSalarySetting>() {{
            last("limit 1");
        }});
        if (salarySetting.getType() == 1) {
            LocalDate localDate = LocalDate.parse(workDateFrame + "-01", DateTimeFormatter.ISO_LOCAL_DATE);
            LocalDate previousMonth = localDate.minusMonths(1);
            String previousMonthStr = previousMonth.format(DateTimeFormatter.ofPattern("yyyy-MM"));
            JSONObject jsonObject = hrmProgrammeService.generateRecord(employeeId, previousMonthStr);
            grgjj = jsonObject.getBigDecimal("gJJGRHj");
            grsb = jsonObject.getBigDecimal("sBGRHj");
        } else if (salarySetting.getType() == 2) {
            LocalDate localDate = LocalDate.parse(workDateFrame + "-01", DateTimeFormatter.ISO_LOCAL_DATE);
            String previousMonthStr = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM"));
            JSONObject jsonObject = hrmProgrammeService.generateRecord(employeeId, previousMonthStr);
            grgjj = jsonObject.getBigDecimal("gJJGRHj");
            grsb = jsonObject.getBigDecimal("sBGRHj");
        }
        HrmSalaryPlan hrmSalaryPlan = hrmSalaryPlanMapper.selectById(salaryPlanEmployee.getPlanId());
        BigDecimal sfAmount = BigDecimal.ZERO;
        BigDecimal yfAmount = BigDecimal.ZERO;
        BigDecimal kgAmount = BigDecimal.ZERO;
        BigDecimal cdAmount = BigDecimal.ZERO;
        BigDecimal ztAmount = BigDecimal.ZERO;
        BigDecimal qjAmount = BigDecimal.ZERO;
        BigDecimal sbAmount = BigDecimal.ZERO;
        BigDecimal gjjAmount = BigDecimal.ZERO;
        BigDecimal qkAmount = BigDecimal.ZERO;
        String zxDate = workDateFrame + "-15";
        Long regularizationTimeLong = employeeDO.getRegularizationTime() != null ? employeeDO.getRegularizationTime().atZone(ZoneOffset.UTC).toInstant().toEpochMilli() : 0L;
        LocalDate date = LocalDate.parse(workDateFrame + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        // 获取该月的开始日
        Long startOfMonth = date.with(TemporalAdjusters.firstDayOfMonth()).atStartOfDay().atZone(ZoneOffset.UTC).toInstant().toEpochMilli();
        // 获取该月的结束日
        Long endOfMonth = date.with(TemporalAdjusters.lastDayOfMonth()).atStartOfDay().atZone(ZoneOffset.UTC).toInstant().toEpochMilli();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        String regularizationTime = employeeDO.getRegularizationTime() != null ? employeeDO.getRegularizationTime().format(formatter) : "";
        String format = date.format(formatter);
        String monthFirst = DateUtil.monthFirstDay(format);
        String monthEnd = DateUtil.monthEndDay(format);
        SystemAttendanceTeam systemAttendanceTeam = systemAttendanceTeamMapper.selectOne(new LambdaQueryWrapper<SystemAttendanceTeam>() {{
            like(SystemAttendanceTeam::getAdaptPerson, "%," + employeeDO.getId()+",%");
            last("limit 1");
        }});
        //整月考勤用于计算旷工、迟到、缺卡 等
        List<SystemColumnValue> allColumnValues = systemColumnValueMapper.selectList(new LambdaQueryWrapper<SystemColumnValue>() {{
            eq(SystemColumnValue::getDate, workDateFrame);
            eq(SystemColumnValue::getDingUserId, employeeDO.getId());
        }});
        //计算迟到扣款 迟到次数
        if (systemAttendanceTeam.getLateRulesType() == 1) {
            SystemColumnTenant cdDingColumn = systemColumnTenantMapper.selectOne(new LambdaQueryWrapper<SystemColumnTenant>() {{
                eq(SystemColumnTenant::getAlias, "late_minute");
                eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                last("limit 1");
            }});
            Double lateTimeMinutes = allColumnValues.stream().filter(d -> d.getColumnId() == cdDingColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
            if (lateTimeMinutes != 0) {
                //按照迟到分钟数扣款
                BigDecimal kkMinute = new BigDecimal(lateTimeMinutes).divide(new BigDecimal(systemAttendanceTeam.getLateMinute()), 0, RoundingMode.DOWN);
                cdAmount = cdAmount.add(new BigDecimal(systemAttendanceTeam.getLateAmount()).multiply(kkMinute));
            }
        } else if (systemAttendanceTeam.getLateRulesType() == 2) {
            SystemColumnTenant cdDingColumn = systemColumnTenantMapper.selectOne(new LambdaQueryWrapper<SystemColumnTenant>() {{
                eq(SystemColumnTenant::getAlias, "late_times");
                eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                last("limit 1");
            }});
            //迟到次数
            Double lateTimeDays = allColumnValues.stream().filter(d -> d.getColumnId() == cdDingColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
            if (lateTimeDays != 0) {
                BigDecimal kkMinute = new BigDecimal(lateTimeDays).divide(new BigDecimal(systemAttendanceTeam.getLateMinute()), 0, RoundingMode.DOWN);
                cdAmount = cdAmount.add(new BigDecimal(systemAttendanceTeam.getLateAmount()).multiply(kkMinute));
            }
        }
        else
        {

            SystemColumnTenant cdDingColumn = systemColumnTenantMapper.selectOne(new LambdaQueryWrapper<SystemColumnTenant>() {{
                eq(SystemColumnTenant::getAlias, "late_times");
                eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                last("limit 1");
            }});
            //迟到次数
            Double lateTimeDays = allColumnValues.stream().filter(d -> d.getColumnId() == cdDingColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
            if (lateTimeDays > 0) {
                cdAmount = new BigDecimal(systemAttendanceTeam.getLateAmount());
            }
        }
        //计算早退扣款
        if (systemAttendanceTeam.getLeaveEarlyRulesType() == 1) {
            SystemColumnTenant cdDingColumn = systemColumnTenantMapper.selectOne(new LambdaQueryWrapper<SystemColumnTenant>() {{
                eq(SystemColumnTenant::getAlias, "leave_early_minute");
                eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                last("limit 1");
            }});
            Double leaveEarlyMinutes = allColumnValues.stream().filter(d -> d.getColumnId() == cdDingColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
            //按照早退分钟数扣款
            if (leaveEarlyMinutes != 0) {
                BigDecimal kkMinute = new BigDecimal(leaveEarlyMinutes).divide(new BigDecimal(systemAttendanceTeam.getLeaveEarlyMinute()), 0, RoundingMode.DOWN);
                ztAmount = ztAmount.add(new BigDecimal(systemAttendanceTeam.getLeaveEarlyAmount()).multiply(kkMinute));
            }
        } else if (systemAttendanceTeam.getLeaveEarlyRulesType() == 2) {
            SystemColumnTenant cdDingColumn = systemColumnTenantMapper.selectOne(new LambdaQueryWrapper<SystemColumnTenant>() {{
                eq(SystemColumnTenant::getAlias, "leave_early_times");
                eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                last("limit 1");
            }});
            Double leaveEarlyMinutes = allColumnValues.stream().filter(d -> d.getColumnId() == cdDingColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
            if (leaveEarlyMinutes > 0) {
                //按照早退次数数扣款
                BigDecimal kkMinute = new BigDecimal(leaveEarlyMinutes).divide(new BigDecimal(systemAttendanceTeam.getLeaveEarlyMinute()));
                ztAmount = ztAmount.add(new BigDecimal(systemAttendanceTeam.getLeaveEarlyAmount()).multiply(kkMinute));
            }
        } else {
            SystemColumnTenant cdDingColumn = systemColumnTenantMapper.selectOne(new LambdaQueryWrapper<SystemColumnTenant>() {{
                eq(SystemColumnTenant::getAlias, "leave_early_times");
                eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                last("limit 1");
            }});
            Double leaveEarlyMinutes = allColumnValues.stream().filter(d -> d.getColumnId() == cdDingColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
            if (leaveEarlyMinutes > 0) {
                //按照早退次数数扣款
                BigDecimal kkMinute = new BigDecimal(leaveEarlyMinutes).divide(new BigDecimal(systemAttendanceTeam.getLeaveEarlyMinute()));
                ztAmount = ztAmount.add(new BigDecimal(systemAttendanceTeam.getLeaveEarlyAmount()).multiply(kkMinute));
            }
        }
        SystemColumnTenant qkSbDingColumn = systemColumnTenantMapper.selectOne(new LambdaQueryWrapper<SystemColumnTenant>() {{
            eq(SystemColumnTenant::getAlias, "off_work_lack_card_times");
            eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
            last("limit 1");
        }});
        SystemColumnTenant qkXbDingColumn = systemColumnTenantMapper.selectOne(new LambdaQueryWrapper<SystemColumnTenant>() {{
            eq(SystemColumnTenant::getAlias, "off_work_lack_card_times");
            eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
            last("limit 1");
        }});

        Double qkSbCount = allColumnValues.stream().filter(d -> d.getColumnId() == qkSbDingColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
        Double qkXbCount = allColumnValues.stream().filter(d -> d.getColumnId() == qkXbDingColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
        qkAmount = new BigDecimal(qkSbCount + qkXbCount).multiply(new BigDecimal(systemAttendanceTeam.getMissingCardNum()));
        //工资表展示基本工资 根据不同情况下面会有变更
        HrmSalaryFixed hrmShowFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
            eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
            eq(HrmSalaryFixed::getIsEffect, 1);
            orderByDesc(HrmSalaryFixed::getDate);
            last("limit 1");
        }});
        SystemColumnTenant answerRequiredColumn = systemColumnTenantMapper.selectOne(new LambdaQueryWrapper<SystemColumnTenant>() {{
            eq(SystemColumnTenant::getAlias, "should_attendance_days");
            eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
        }});
        SystemColumnTenant attendanceRequiredColumn = systemColumnTenantMapper.selectOne(new LambdaQueryWrapper<SystemColumnTenant>() {{
            eq(SystemColumnTenant::getAlias, "attendance_days");
            eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
        }});
        //本月考勤
        List<SystemColumnValue> dingColumnValues = systemColumnValueMapper.selectList(new LambdaQueryWrapper<SystemColumnValue>() {{
            eq(SystemColumnValue::getDate, workDateFrame);
//            lt(SystemColumnValue::getDate, monthEnd + " 00:00:00");
            eq(SystemColumnValue::getDingUserId, employeeDO.getId());
        }});
        //应出勤
        Double formalPeriodAnswerRequired2 = dingColumnValues.stream().filter(d -> d.getColumnId() == answerRequiredColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
//        //实际出勤
//        Integer formalPeriodAttendanceRequired2 = dingColumnValues.stream().filter(d -> d.getColumnId() == attendanceRequiredColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
        //计算旷工
        SystemColumnTenant  zzKgColumn = systemColumnTenantMapper.selectOne(new LambdaQueryWrapper<SystemColumnTenant>() {{
            eq(SystemColumnTenant::getAlias, "absenteeism_days");
            eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
        }});
        Double kgDays = dingColumnValues.stream().filter(d -> d.getColumnId() == zzKgColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
        if (employeeDO.getState() == 3 && regularizationTimeLong >= startOfMonth && regularizationTimeLong <= endOfMonth) {
            switch (hrmSalaryPlan.getMonthlySalaryStandard()) {
                case 1:
                    switch (hrmSalaryPlan.getSalaryAdjustmentRules()) {
                        case 1:
                            //判断是不是15号前转正
                            Long l = DateUtil.strZLong(zxDate + " 23:59:59");
                            if (regularizationTimeLong > l) {
                                //十五号后转正
                                //转正前最后一次的调薪
                                HrmSalaryFixed zzqHrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
                                    le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                                    eq(HrmSalaryFixed::getIsEffect, 1);
                                    orderByDesc(HrmSalaryFixed::getDate);
                                    last("limit 1");
                                }});
                                if (ObjectUtils.isEmpty(zzqHrmSalaryFixed)) {
                                    sfAmount = sfAmount.add(BigDecimal.ZERO);
                                    yfAmount = yfAmount.add(BigDecimal.ZERO);
                                } else {
                                    List<HrmSalaryFixedTable> zzqhrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                        eq(HrmSalaryFixedTable::getFixedId, zzqHrmSalaryFixed.getId());
                                    }});
                                    for (HrmSalaryFixedTable hrmSalaryFixedTable : zzqhrmSalaryFixedTableList) {
                                        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                        if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                                            continue;
                                        }
                                        HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                                        hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                                        hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
                                        hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                                        hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                                        hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                                        sfAmount = sfAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
                                        yfAmount = yfAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
                                    }
                                }
//                                if (formalPeriodAnswerRequired2 != formalPeriodAttendanceRequired2) {
//                                    if (sfAmount.compareTo(BigDecimal.ZERO) != 0) {
//                                        sfAmount = sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                        yfAmount = yfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                    }
//                                }
                                if (kgDays != 0) {
                                    if (systemAttendanceTeam.getAbsenteeRulesType() == 1) {
                                        //按照旷工次数扣款
                                        kgAmount = kgAmount.add(sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(kgDays)));
                                    } else {
                                        kgAmount = kgAmount.add(new BigDecimal(kgDays).multiply(new BigDecimal(systemAttendanceTeam.getAbsenteeAmount())));
                                        //按照基本工资的百分比扣款

                                    }
                                }
                                List<SystemColumnTenant> systemColumnTenants = systemColumnTenantMapper.selectList(new LambdaQueryWrapper<SystemColumnTenant>() {{
                                    isNotNull(SystemColumnTenant::getGenceId);
                                    eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                                }});
                                for (SystemColumnTenant systemColumnTenant : systemColumnTenants) {
                                    //来区分通过 天还是小时请的假
                                    List<SystemColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).collect(Collectors.toList());
                                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).count();
//                                    //计算每个小时薪资是多少
//                                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
//                                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
//                                        last("limit 1");
//                                    }});
//                                    if (ObjectUtils.isEmpty(dingClassTeam)) {
//
//                                        continue;
//                                    }
//                                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
//                                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
//                                    }});
//                                    //当前班次每天上多久班
//                                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                                    vacationHour = vacationHour.add(new BigDecimal(8).multiply(vacationDay));
                                    //时薪是多少
                                    BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP).divide(new BigDecimal(8), 2, RoundingMode.HALF_UP);
                                    SystemFalseDiligence dingFalseDiligence = systemFalseDiligenceMapper.selectById(systemColumnTenant.getGenceId());
                                    switch (dingFalseDiligence.getLeaveRulesType()) {
                                        case 1:
                                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                                            break;
                                        case 2:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                                            break;
                                        case 3:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                                            break;
                                    }
                                }
//                                yfAmount = yfAmount.subtract(kgAmount);
//                                sfAmount = sfAmount.subtract(kgAmount);
                            } else {
                                //十五号及十五号前转正
                                //转正后最后一次的调薪
                                HrmSalaryFixed zzhHrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
                                    eq(HrmSalaryFixed::getIsEffect, 1);
                                    orderByDesc(HrmSalaryFixed::getDate);
                                    last("limit 1");
                                }});
                                if (ObjectUtils.isEmpty(zzhHrmSalaryFixed)) {
                                    sfAmount = sfAmount.add(BigDecimal.ZERO);
                                    yfAmount = yfAmount.add(BigDecimal.ZERO);
                                } else {
                                    List<HrmSalaryFixedTable> zzhhrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                        eq(HrmSalaryFixedTable::getFixedId, zzhHrmSalaryFixed.getId());
                                    }});
                                    for (HrmSalaryFixedTable hrmSalaryFixedTable : zzhhrmSalaryFixedTableList) {
                                        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                        if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                                            continue;
                                        }
                                        HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                                        hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                                        hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                                        hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
                                        hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                                        hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                                        sfAmount = sfAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                                        yfAmount = yfAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                                    }
                                }
//                                if (formalPeriodAnswerRequired2 != formalPeriodAttendanceRequired2) {
//                                    if (sfAmount.compareTo(BigDecimal.ZERO) != 0) {
//                                        sfAmount = sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                        yfAmount = yfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                    }
//                                }
                                if (kgDays != 0) {
                                    if (systemAttendanceTeam.getAbsenteeRulesType() == 1) {
                                        //按照旷工次数扣款
                                        kgAmount = kgAmount.add(sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(kgDays)));

                                    } else {
                                        kgAmount = kgAmount.add(new BigDecimal(kgDays).multiply(new BigDecimal(systemAttendanceTeam.getAbsenteeAmount())));
                                        //按照基本工资的百分比扣款
                                    }
                                }
//                                yfAmount = yfAmount.subtract(kgAmount);
//                                sfAmount = sfAmount.subtract(kgAmount);

                                List<SystemColumnTenant>   systemColumnTenants = systemColumnTenantMapper.selectList(new LambdaQueryWrapper<SystemColumnTenant>() {{
                                    isNotNull(SystemColumnTenant::getGenceId);
                                    eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                                }});
                                for (SystemColumnTenant systemColumnTenant : systemColumnTenants) {
                                    //来区分通过 天还是小时请的假
                                    List<SystemColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).collect(Collectors.toList());
                                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).count();
//                                    //计算每个小时薪资是多少
//                                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
//                                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
//                                        last("limit 1");
//                                    }});
//                                    if (ObjectUtils.isEmpty(dingClassTeam)) {
//
//                                        continue;
//                                    }
//                                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
//                                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
//                                    }});
//                                    //当前班次每天上多久班
//                                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                                    vacationHour = vacationHour.add(new BigDecimal(8).multiply(vacationDay));
                                    //时薪是多少
                                    BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP).divide(new BigDecimal(8), 2, RoundingMode.HALF_UP);
                                    SystemFalseDiligence dingFalseDiligence = systemFalseDiligenceMapper.selectById(systemColumnTenant.getGenceId());
                                    switch (dingFalseDiligence.getLeaveRulesType()) {
                                        case 1:
                                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                                            break;
                                        case 2:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                                            break;
                                        case 3:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                                            break;
                                    }
                                }
                            }
                            break;
                        case 2:
                            //整月按照转正薪资算
                            //转正后最后一次的调薪
                            HrmSalaryFixed zzhMonthHrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                                eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
                                eq(HrmSalaryFixed::getIsEffect, 1);
                                orderByDesc(HrmSalaryFixed::getDate);
                                last("limit 1");
                            }});
                            if (ObjectUtils.isEmpty(zzhMonthHrmSalaryFixed)) {
                                sfAmount = sfAmount.add(BigDecimal.ZERO);
                                yfAmount = yfAmount.add(BigDecimal.ZERO);
                            } else {
                                List<HrmSalaryFixedTable> zzhMonthHrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                    eq(HrmSalaryFixedTable::getFixedId, zzhMonthHrmSalaryFixed.getId());
                                }});
                                for (HrmSalaryFixedTable hrmSalaryFixedTable : zzhMonthHrmSalaryFixedTableList) {
                                    HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                    if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                                        continue;
                                    }
                                    HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                                    hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                                    hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
                                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                                    hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                                    hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                                    sfAmount = sfAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                                    yfAmount = yfAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                                }
                            }

                            if (kgDays != 0) {
                                if (systemAttendanceTeam.getAbsenteeRulesType() == 1) {
                                    //按照旷工次数扣款
                                    kgAmount = kgAmount.add(sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(kgDays)));
                                } else {
                                    kgAmount = kgAmount.add(new BigDecimal(kgDays).multiply(new BigDecimal(systemAttendanceTeam.getAbsenteeAmount())));
                                    //按照基本工资的百分比扣款

                                }
                            }
                            List<SystemColumnTenant> systemColumnTenants = systemColumnTenantMapper.selectList(new LambdaQueryWrapper<SystemColumnTenant>() {{
                                isNotNull(SystemColumnTenant::getGenceId);
                                eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                            }});
                            for (SystemColumnTenant systemColumnTenant : systemColumnTenants) {
                                //来区分通过 天还是小时请的假
                                List<SystemColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).collect(Collectors.toList());
                                BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).count();
//                                //计算每个小时薪资是多少
//                                DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
//                                    eq(DingClassTeam::getTeamId, dingUser.getTeamId());
//                                    last("limit 1");
//                                }});
//                                if (ObjectUtils.isEmpty(dingClassTeam)) {
//
//                                    continue;
//                                }
//                                DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
//                                    eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
//                                }});
                                //当前班次每天上多久班
//                                BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                                vacationHour = vacationHour.add(new BigDecimal(8).multiply(vacationDay));
                                //时薪是多少
                                BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP).divide(new BigDecimal(8), 2, RoundingMode.HALF_UP);
                                SystemFalseDiligence dingFalseDiligence = systemFalseDiligenceMapper.selectById(systemColumnTenant.getGenceId());
                                switch (dingFalseDiligence.getLeaveRulesType()) {
                                    case 1:
                                        qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                                        break;
                                    case 2:
                                        qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                                        break;
                                    case 3:
                                        qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                                        break;
                                }
                            }
//                            yfAmount = yfAmount.subtract(kgAmount);
//                            sfAmount = sfAmount.subtract(kgAmount);

                            break;
                        case 3:
                            //判断是不是15号前转正
                           l = DateUtil.strZLong(zxDate + " 23:59:59");
                            if (regularizationTimeLong > l) {
                                //十五号后转正
                                //转正前最后一次的调薪
                                HrmSalaryFixed zzqHrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
                                    le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                                    eq(HrmSalaryFixed::getIsEffect, 1);
                                    orderByDesc(HrmSalaryFixed::getDate);
                                    last("limit 1");
                                }});
                                if (ObjectUtils.isEmpty(zzqHrmSalaryFixed)) {
                                    sfAmount = sfAmount.add(BigDecimal.ZERO);
                                    yfAmount = yfAmount.add(BigDecimal.ZERO);
                                } else {
                                    List<HrmSalaryFixedTable> zzqhrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                        eq(HrmSalaryFixedTable::getFixedId, zzqHrmSalaryFixed.getId());
                                    }});
                                    for (HrmSalaryFixedTable hrmSalaryFixedTable : zzqhrmSalaryFixedTableList) {
                                        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                        if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                                            continue;
                                        }
                                        HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                                        hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                                        hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
                                        hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                                        hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                                        hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                                        sfAmount = sfAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
                                        yfAmount = yfAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
                                    }
                                }
//                                if (formalPeriodAnswerRequired2 != formalPeriodAttendanceRequired2) {
//                                    if (sfAmount.compareTo(BigDecimal.ZERO) != 0) {
//                                        sfAmount = sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                        yfAmount = yfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                    }
//                                }
                                if (kgDays != 0) {
                                    if (systemAttendanceTeam.getAbsenteeRulesType() == 1) {
                                        //按照旷工次数扣款
                                        kgAmount = kgAmount.add(sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(kgDays)));
                                    } else {
                                        kgAmount = kgAmount.add(new BigDecimal(kgDays).multiply(new BigDecimal(systemAttendanceTeam.getAbsenteeAmount())));
                                        //按照基本工资的百分比扣款

                                    }
                                }
                                systemColumnTenants = systemColumnTenantMapper.selectList(new LambdaQueryWrapper<SystemColumnTenant>() {{
                                    isNotNull(SystemColumnTenant::getGenceId);
                                    eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                                }});
                                for (SystemColumnTenant systemColumnTenant : systemColumnTenants) {
                                    //来区分通过 天还是小时请的假
                                    List<SystemColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).collect(Collectors.toList());
                                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).count();
//                                    //计算每个小时薪资是多少
//                                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
//                                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
//                                        last("limit 1");
//                                    }});
//                                    if (ObjectUtils.isEmpty(dingClassTeam)) {
//
//                                        continue;
//                                    }
//                                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
//                                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
//                                    }});
//                                    //当前班次每天上多久班
//                                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                                    vacationHour = vacationHour.add(new BigDecimal(8).multiply(vacationDay));
                                    //时薪是多少
                                    BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP).divide(new BigDecimal(8), 2, RoundingMode.HALF_UP);
                                    SystemFalseDiligence dingFalseDiligence = systemFalseDiligenceMapper.selectById(systemColumnTenant.getGenceId());
                                    switch (dingFalseDiligence.getLeaveRulesType()) {
                                        case 1:
                                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                                            break;
                                        case 2:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                                            break;
                                        case 3:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                                            break;
                                    }
                                }
//                                yfAmount = yfAmount.subtract(kgAmount);
//                                sfAmount = sfAmount.subtract(kgAmount);
                            } else {
                                //十五号及十五号前转正
                                //转正后最后一次的调薪
                                HrmSalaryFixed zzhHrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
//                                    le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                                    eq(HrmSalaryFixed::getIsEffect, 1);
                                    orderByDesc(HrmSalaryFixed::getDate);
                                    last("limit 1");
                                }});
                                if (ObjectUtils.isEmpty(zzhHrmSalaryFixed)) {
                                    sfAmount = sfAmount.add(BigDecimal.ZERO);
                                    yfAmount = yfAmount.add(BigDecimal.ZERO);
                                } else {
                                    List<HrmSalaryFixedTable> zzhhrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                        eq(HrmSalaryFixedTable::getFixedId, zzhHrmSalaryFixed.getId());
                                    }});
                                    for (HrmSalaryFixedTable hrmSalaryFixedTable : zzhhrmSalaryFixedTableList) {
                                        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                        if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                                            continue;
                                        }
                                        HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                                        hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                                        hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                                        hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
                                        hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                                        hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                                        sfAmount = sfAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                                        yfAmount = yfAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                                    }
                                }
//                                if (formalPeriodAnswerRequired2 != formalPeriodAttendanceRequired2) {
//                                    if (sfAmount.compareTo(BigDecimal.ZERO) != 0) {
//                                        sfAmount = sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                        yfAmount = yfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                    }
//                                }
                                if (kgDays != 0) {
                                    if (systemAttendanceTeam.getAbsenteeRulesType() == 1) {
                                        //按照旷工次数扣款
                                        kgAmount = kgAmount.add(sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(kgDays)));

                                    } else {
                                        kgAmount = kgAmount.add(new BigDecimal(kgDays).multiply(new BigDecimal(systemAttendanceTeam.getAbsenteeAmount())));
                                        //按照基本工资的百分比扣款
                                    }
                                }
//                                yfAmount = yfAmount.subtract(kgAmount);
//                                sfAmount = sfAmount.subtract(kgAmount);

                                systemColumnTenants = systemColumnTenantMapper.selectList(new LambdaQueryWrapper<SystemColumnTenant>() {{
                                    isNotNull(SystemColumnTenant::getGenceId);
                                    eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                                }});
                                for (SystemColumnTenant systemColumnTenant : systemColumnTenants) {
                                    //来区分通过 天还是小时请的假
                                    List<SystemColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).collect(Collectors.toList());
                                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).count();
//                                    //计算每个小时薪资是多少
//                                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
//                                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
//                                        last("limit 1");
//                                    }});
//                                    if (ObjectUtils.isEmpty(dingClassTeam)) {
//
//                                        continue;
//                                    }
//                                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
//                                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
//                                    }});
//                                    //当前班次每天上多久班
//                                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                                    vacationHour = vacationHour.add(new BigDecimal(8).multiply(vacationDay));
                                    //时薪是多少
                                    BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP).divide(new BigDecimal(8), 2, RoundingMode.HALF_UP);
                                    SystemFalseDiligence dingFalseDiligence = systemFalseDiligenceMapper.selectById(systemColumnTenant.getGenceId());
                                    switch (dingFalseDiligence.getLeaveRulesType()) {
                                        case 1:
                                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                                            break;
                                        case 2:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                                            break;
                                        case 3:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                                            break;
                                    }
                                }
                            }
                            break;
                    }
                    break;
                case 2:
                    switch (hrmSalaryPlan.getSalaryAdjustmentRules()) {
//                        case 1:
//                            HrmSalaryFixed finalHrmShowFixed = hrmShowFixed;
//                            List<HrmSalaryFixedTable> hrmShowSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                                eq(HrmSalaryFixedTable::getFixedId, finalHrmShowFixed.getId());
//                            }});
//                            for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmShowSalaryFixedTableList) {
//                                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
//                                HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
//                                hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
//                                hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryFixedTable.getId());
//                                hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
//                                hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
//                                hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
//                            }
//                            //试用期前的考勤
//                            List<SystemColumnValue> trialPeriodDingColumnValues = systemColumnValueMapper.selectList(new LambdaQueryWrapper<SystemColumnValue>() {{
//                                ge(SystemColumnValue::getDate, monthFirst + " 00:00:00");
//                                lt(SystemColumnValue::getDate, regularizationTime + " 00:00:00");
//                                eq(SystemColumnValue::getDingUserId, employeeDO.getDingUserId());
//                            }});
//                            //转正后的考勤
//                            List<DingColumnValue> formalDingColumnValues = dingColumnValueMapper.selectList(new LambdaQueryWrapper<DingColumnValue>() {{
//                                ge(DingColumnValue::getDate, regularizationTime + " 00:00:00");
//                                le(DingColumnValue::getDate, monthEnd + " 00:00:00");
//                                eq(DingColumnValue::getDingUserId, employeeDO.getDingUserId());
//                            }});
//                            //试用期薪资
//                            HrmSalaryFixed hrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//                                eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
//                                le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
//                                eq(HrmSalaryFixed::getIsEffect, 1);
//                                orderByDesc(HrmSalaryFixed::getDate);
//                                last("limit 1");
//                            }});
//                            //计算薪资合计
//                            //试用期应出勤
//                            Double trialPeriodAnswerRequired = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == answerRequiredColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
////                            //实际出勤
////                            Integer trialPeriodAttendanceRequired = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == attendanceRequiredColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
//                            List<HrmSalaryFixedTable> hrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                                eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed.getId());
//                            }});
//                            //基本项工资
//                            BigDecimal syqAmount = BigDecimal.ZERO;
//                            BigDecimal syJbAmount = BigDecimal.ZERO;
//                            for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTableList) {
//                                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
//                                if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                                    continue;
//                                }
//                                syJbAmount = syJbAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
//                            }
//                            //如果应出勤是0那就全额工资 否则就计算基础工资/应出勤天数*试用期应出勤天数
//                            if (trialPeriodAnswerRequired == 0) {
//                                syqAmount = BigDecimal.ZERO;
//                            } else {
//                                //按照上班天数扣款
//                                syqAmount = syJbAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(trialPeriodAnswerRequired));
//                                List<SystemColumnTenant> systemColumnTenants = systemColumnTenantMapper.selectList(new LambdaQueryWrapper<SystemColumnTenant>() {{
//                                    isNotNull(SystemColumnTenant::getGenceId);
//                                    eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
//                                }});
//                                for (SystemColumnTenant systemColumnTenant : systemColumnTenants) {
//                                    //来区分通过 天还是小时请的假
//                                    List<SystemColumnValue> collect2 = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).collect(Collectors.toList());
//                                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
//                                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
//                                    Long count = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).count();
////                                    //计算每个小时薪资是多少
////                                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
////                                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
////                                        last("limit 1");
////                                    }});
////                                    if (ObjectUtils.isEmpty(dingClassTeam)) {
////
////                                        continue;
////                                    }
////                                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
////                                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
////                                    }});
////                                    //当前班次每天上多久班
////                                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
//                                    vacationHour = vacationHour.add(new BigDecimal(8).multiply(vacationDay));
//                                    //时薪是多少
//                                    BigDecimal hoursAmount = syJbAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).divide(new BigDecimal(8), 2, RoundingMode.HALF_UP);
//                                    DingFalseDiligence dingFalseDiligence = dingFalseDiligenceMapper.selectById(systemColumnTenant.getGenceId());
//                                    switch (dingFalseDiligence.getLeaveRulesType()) {
//                                        case 1:
//                                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
//                                            break;
//                                        case 2:
//                                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
//                                            break;
//                                        case 3:
//                                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
//                                            break;
//                                    }
//                                }
//
//
//                            }
//                            //计算旷工
//                            DingColumn kgColumn = dingColumnMapper.selectOne(new LambdaQueryWrapper<DingColumn>() {{
//                                eq(DingColumn::getAlias, "absenteeism_days");
//                                eq(DingColumn::getTenantId, employeeDO.getTenantId());
//                            }});
//                            Double hgDays = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == kgColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
//
//                            if (hgDays != 0) {
//                                if (systemAttendanceTeam.getAbsenteeRulesType() == 1) {
//                                    //按照旷工次数扣款
//
//                                    kgAmount = kgAmount.add(syJbAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP)).multiply(new BigDecimal(hgDays));
//                                } else {
//                                    //按照基本工资的百分比扣款
//                                    kgAmount = kgAmount.add(new BigDecimal(hgDays).multiply(new BigDecimal(systemAttendanceTeam.getAbsenteeAmount())));
//                                }
//                            }
//                            //===========================转正后=====================================================================================================================================
//                            //转正后薪资
//                            HrmSalaryFixed zzHrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//                                eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
//                                eq(HrmSalaryFixed::getIsEffect, 1);
//                                orderByDesc(HrmSalaryFixed::getDate);
//                                last("limit 1");
//                            }});
//                            List<HrmSalaryFixedTable> zzHrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
//                                eq(HrmSalaryFixedTable::getFixedId, zzHrmSalaryFixed.getId());
//                            }});
//                            //应出勤
//                            Double formalPeriodAnswerRequired = formalDingColumnValues.stream().filter(d -> d.getColumnId() == answerRequiredColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
////                            //实际出勤
////                            Integer formalPeriodAttendanceRequired = formalDingColumnValues.stream().filter(d -> d.getColumnId() == attendanceRequiredColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
//                            //基本项工资
//                            BigDecimal zzAmount = BigDecimal.ZERO;
//                            BigDecimal zzJbAmount = BigDecimal.ZERO;
//                            for (HrmSalaryFixedTable hrmSalaryFixedTable : zzHrmSalaryFixedTableList) {
//                                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
//                                if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
//                                    continue;
//                                }
//                                zzJbAmount = zzJbAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
//                            }
//                            //如果应出勤是0那就全额工资 否则就计算基础工资/应出勤天数*实际出勤天数
//                            if (trialPeriodAnswerRequired == 0) {
//                            } else {
//                                //按照上班天数扣款
//                                zzAmount = zzJbAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(formalPeriodAnswerRequired));
//                                List<SystemColumnTenant> systemColumnTenants = systemColumnTenantMapper.selectList(new LambdaQueryWrapper<SystemColumnTenant>() {{
//                                    isNotNull(SystemColumnTenant::getGenceId);
//                                    eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
//                                }});
//                                for (SystemColumnTenant systemColumnTenant : systemColumnTenants) {
//                                    //来区分通过 天还是小时请的假
//                                    List<DingColumnValue> collect2 = formalDingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).collect(Collectors.toList());
//                                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
//                                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
//                                    Long count = formalDingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).count();
////                                    //计算每个小时薪资是多少
////                                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
////                                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
////                                        last("limit 1");
////                                    }});
////                                    if (ObjectUtils.isEmpty(dingClassTeam)) {
////                                        continue;
////                                    }
////                                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
////                                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
////                                    }});
////                                    //当前班次每天上多久班
////                                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
//                                    vacationHour = vacationHour.add(new BigDecimal(8).multiply(vacationDay));
//                                    //时薪是多少
//                                    BigDecimal hoursAmount = zzJbAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).divide(new BigDecimal(8), 2, RoundingMode.HALF_UP);
//                                    DingFalseDiligence dingFalseDiligence = dingFalseDiligenceMapper.selectById(systemColumnTenant.getGenceId());
//                                    switch (dingFalseDiligence.getLeaveRulesType()) {
//                                        case 1:
//                                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
//                                            break;
//                                        case 2:
//                                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
//                                            break;
//                                        case 3:
//                                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
//                                            break;
//                                    }
//                                }
//
//                            }
//                            Double zzHgDays = formalDingColumnValues.stream().filter(d -> d.getColumnId() == zzKgColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();
//                            if (zzHgDays != 0) {
//                                if (systemAttendanceTeam.getAbsenteeRulesType() == 1) {
//                                    //按照旷工次数扣款
//                                    kgAmount = kgAmount.add(zzJbAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP)).multiply(new BigDecimal(zzHgDays));
//                                } else {
//                                    kgAmount = kgAmount.add(new BigDecimal(zzHgDays).multiply(new BigDecimal(systemAttendanceTeam.getAbsenteeAmount())));
//                                    //按照基本工资的百分比扣款
//
//                                }
//                            }
//                            //计算总工资
//                            sfAmount = sfAmount.add(syqAmount).add(zzAmount).subtract(kgAmount);
//                            yfAmount = yfAmount.add(syqAmount).add(zzAmount).subtract(kgAmount);
//                            break;

                        case 1:
                            //判断是不是15号前转正
                            Long l = DateUtil.strZLong(zxDate + " 23:59:59");
                            if (regularizationTimeLong > l) {
                                //十五号后转正
                                //转正前最后一次的调薪
                                HrmSalaryFixed zzqHrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
//                                    le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                                    eq(HrmSalaryFixed::getIsEffect, 1);
                                    orderByDesc(HrmSalaryFixed::getDate);
                                    last("limit 1");
                                }});
                                if (ObjectUtils.isEmpty(zzqHrmSalaryFixed)) {
                                    sfAmount = sfAmount.add(BigDecimal.ZERO);
                                    yfAmount = yfAmount.add(BigDecimal.ZERO);
                                } else {
                                    List<HrmSalaryFixedTable> zzqhrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                        eq(HrmSalaryFixedTable::getFixedId, zzqHrmSalaryFixed.getId());
                                    }});
                                    for (HrmSalaryFixedTable hrmSalaryFixedTable : zzqhrmSalaryFixedTableList) {
                                        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                        if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                                            continue;
                                        }
                                        HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                                        hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                                        hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                                        hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeFrontAmount());
                                        hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                                        hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                                        sfAmount = sfAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
                                        yfAmount = yfAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
                                    }
                                }
//                                if (formalPeriodAnswerRequired2 != formalPeriodAttendanceRequired2) {
//                                    if (sfAmount.compareTo(BigDecimal.ZERO) != 0) {
//                                        sfAmount = sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                        yfAmount = yfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                    }
//                                }
                                if (kgDays != 0) {
                                    if (systemAttendanceTeam.getAbsenteeRulesType() == 1) {
                                        //按照旷工次数扣款
                                        kgAmount = kgAmount.add(sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(kgDays)));
                                    } else {
                                        //按照基本工资的百分比扣款

                                        kgAmount = kgAmount.add(new BigDecimal(kgDays).multiply(new BigDecimal(systemAttendanceTeam.getAbsenteeAmount())));
                                    }
                                }
                                List<SystemColumnTenant> systemColumnTenants = systemColumnTenantMapper.selectList(new LambdaQueryWrapper<SystemColumnTenant>() {{
                                    isNotNull(SystemColumnTenant::getGenceId);
                                    eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                                }});
                                for (SystemColumnTenant systemColumnTenant : systemColumnTenants) {
                                    //来区分通过 天还是小时请的假
                                    List<SystemColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).collect(Collectors.toList());
                                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).count();
//                                    //计算每个小时薪资是多少
//                                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
//                                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
//                                        last("limit 1");
//                                    }});
//                                    if (ObjectUtils.isEmpty(dingClassTeam)) {
//
//                                        continue;
//                                    }
//                                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
//                                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
//                                    }});
//                                    //当前班次每天上多久班
//                                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                                    vacationHour = vacationHour.add(new BigDecimal(8).multiply(vacationDay));
                                    //时薪是多少
                                    BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).divide(new BigDecimal(8), 2, RoundingMode.HALF_UP);
                                    SystemFalseDiligence dingFalseDiligence = systemFalseDiligenceMapper.selectById(systemColumnTenant.getGenceId());
                                    switch (dingFalseDiligence.getLeaveRulesType()) {
                                        case 1:
                                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                                            break;
                                        case 2:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                                            break;
                                        case 3:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                                            break;
                                    }
                                }

//                                yfAmount = yfAmount.subtract(kgAmount);
//                                sfAmount = sfAmount.subtract(kgAmount);

                            } else {
                                //十五号及十五号前转正
                                //转正后最后一次的调薪
                                HrmSalaryFixed zzhHrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
//                                    le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                                    eq(HrmSalaryFixed::getIsEffect, 1);
                                    orderByDesc(HrmSalaryFixed::getDate);
                                    last("limit 1");
                                }});
                                if (ObjectUtils.isEmpty(zzhHrmSalaryFixed)) {
                                    sfAmount = sfAmount.add(BigDecimal.ZERO);
                                    yfAmount = yfAmount.add(BigDecimal.ZERO);
                                } else {
                                    List<HrmSalaryFixedTable> zzhhrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                        eq(HrmSalaryFixedTable::getFixedId, zzhHrmSalaryFixed.getId());
                                    }});
                                    for (HrmSalaryFixedTable hrmSalaryFixedTable : zzhhrmSalaryFixedTableList) {
                                        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                        if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                                            continue;
                                        }
                                        HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                                        hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                                        hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                                        hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
                                        hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                                        hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                                        sfAmount = sfAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                                        yfAmount = yfAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                                    }
                                }
//                                    if (formalPeriodAnswerRequired2 != formalPeriodAttendanceRequired2) {
//                                        if (sfAmount.compareTo(BigDecimal.ZERO) != 0) {
//                                            sfAmount = sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                            yfAmount = yfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                        }
//                                    }
                                List<SystemColumnTenant> systemColumnTenants = systemColumnTenantMapper.selectList(new LambdaQueryWrapper<SystemColumnTenant>() {{
                                    isNotNull(SystemColumnTenant::getGenceId);
                                    eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                                }});
                                for (SystemColumnTenant systemColumnTenant : systemColumnTenants) {
                                    //来区分通过 天还是小时请的假
                                    List<SystemColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).collect(Collectors.toList());
                                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).count();
//                                    //计算每个小时薪资是多少
//                                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
//                                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
//                                        last("limit 1");
//                                    }});
//                                    if (ObjectUtils.isEmpty(dingClassTeam)) {
//
//                                        continue;
//                                    }
//                                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
//                                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
//                                    }});
//                                    //当前班次每天上多久班
//                                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                                    vacationHour = vacationHour.add(new BigDecimal(8).multiply(vacationDay));
                                    //时薪是多少
                                    BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).divide(new BigDecimal(8), 2, RoundingMode.HALF_UP);
                                    SystemFalseDiligence dingFalseDiligence = systemFalseDiligenceMapper.selectById(systemColumnTenant.getGenceId());
                                    switch (dingFalseDiligence.getLeaveRulesType()) {
                                        case 1:
                                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                                            break;
                                        case 2:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                                            break;
                                        case 3:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                                            break;
                                    }
                                }
                                if (kgDays != 0) {
                                    if (systemAttendanceTeam.getAbsenteeRulesType() == 1) {
                                        //按照旷工次数扣款
                                        kgAmount = kgAmount.add(sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(kgDays)));
                                    } else {
                                        kgAmount = kgAmount.add(new BigDecimal(kgDays).multiply(new BigDecimal(systemAttendanceTeam.getAbsenteeAmount())));
                                        //按照基本工资的百分比扣款

                                    }
                                }
//                                yfAmount = yfAmount.subtract(kgAmount);
//                                sfAmount = sfAmount.subtract(kgAmount);
                            }
                            break;
                        case 2:
                            //整月按照转正薪资算
                            //转正后最后一次的调薪
                            HrmSalaryFixed zzhMonthHrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                                eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
                                eq(HrmSalaryFixed::getIsEffect, 1);
                                orderByDesc(HrmSalaryFixed::getDate);
                                last("limit 1");
                            }});
                            if (ObjectUtils.isEmpty(zzhMonthHrmSalaryFixed)) {
                                sfAmount = sfAmount.add(BigDecimal.ZERO);
                                yfAmount = yfAmount.add(BigDecimal.ZERO);
                            } else {
                                List<HrmSalaryFixedTable> zzhMonthHrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                    eq(HrmSalaryFixedTable::getFixedId, zzhMonthHrmSalaryFixed.getId());
                                }});
                                for (HrmSalaryFixedTable hrmSalaryFixedTable : zzhMonthHrmSalaryFixedTableList) {
                                    HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                    if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                                        continue;
                                    }
                                    HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                                    hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                                    hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
                                    hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                                    hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                                    sfAmount = sfAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                                    yfAmount = yfAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                                }
                            }
                            if (kgDays != 0) {
                                if (systemAttendanceTeam.getAbsenteeRulesType() == 1) {
                                    //按照旷工次数扣款

                                    kgAmount = kgAmount.add(sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(kgDays)));
                                } else {
                                    //按照基本工资的百分比扣款
                                    kgAmount = kgAmount.add(new BigDecimal(kgDays).multiply(new BigDecimal(systemAttendanceTeam.getAbsenteeAmount())));
                                }
                            }
                            List<SystemColumnTenant> systemColumnTenants = systemColumnTenantMapper.selectList(new LambdaQueryWrapper<SystemColumnTenant>() {{
                                isNotNull(SystemColumnTenant::getGenceId);
                                eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                            }});
                            for (SystemColumnTenant systemColumnTenant : systemColumnTenants) {
                                //来区分通过 天还是小时请的假
                                List<SystemColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).collect(Collectors.toList());
                                BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).count();
//                                //计算每个小时薪资是多少
//                                DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
//                                    eq(DingClassTeam::getTeamId, dingUser.getTeamId());
//                                    last("limit 1");
//                                }});
//                                if (ObjectUtils.isEmpty(dingClassTeam)) {
//                                    continue;
//                                }
//                                DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
//                                    eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
//                                }});
//                                //当前班次每天上多久班
//                                BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                                vacationHour = vacationHour.add(new BigDecimal(8).multiply(vacationDay));
                                //时薪是多少
                                BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).divide(new BigDecimal(8), 2, RoundingMode.HALF_UP);
                                SystemFalseDiligence dingFalseDiligence = systemFalseDiligenceMapper.selectById(systemColumnTenant.getGenceId());
                                switch (dingFalseDiligence.getLeaveRulesType()) {
                                    case 1:
                                        qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                                        break;
                                    case 2:
                                        qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                                        break;
                                    case 3:
                                        qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                                        break;
                                }
                            }


//                            yfAmount = yfAmount.subtract(kgAmount);
//                            sfAmount = sfAmount.subtract(kgAmount);
                            break;
                        case 3:
                            //判断是不是15号前转正
                          l = DateUtil.strZLong(zxDate + " 23:59:59");
                            if (regularizationTimeLong > l) {
                                //十五号后转正
                                //转正前最后一次的调薪
                                HrmSalaryFixed zzqHrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
//                                    le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                                    eq(HrmSalaryFixed::getIsEffect, 1);
                                    orderByDesc(HrmSalaryFixed::getDate);
                                    last("limit 1");
                                }});
                                if (ObjectUtils.isEmpty(zzqHrmSalaryFixed)) {
                                    sfAmount = sfAmount.add(BigDecimal.ZERO);
                                    yfAmount = yfAmount.add(BigDecimal.ZERO);
                                } else {
                                    List<HrmSalaryFixedTable> zzqhrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                        eq(HrmSalaryFixedTable::getFixedId, zzqHrmSalaryFixed.getId());
                                    }});
                                    for (HrmSalaryFixedTable hrmSalaryFixedTable : zzqhrmSalaryFixedTableList) {
                                        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                        if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                                            continue;
                                        }
                                        HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                                        hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                                        hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                                        hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeFrontAmount());
                                        hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                                        hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);

                                        sfAmount = sfAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
                                        yfAmount = yfAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
                                    }
                                }
//                                if (formalPeriodAnswerRequired2 != formalPeriodAttendanceRequired2) {
//                                    if (sfAmount.compareTo(BigDecimal.ZERO) != 0) {
//                                        sfAmount = sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                        yfAmount = yfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                    }
//                                }
                                if (kgDays != 0) {
                                    if (systemAttendanceTeam.getAbsenteeRulesType() == 1) {
                                        //按照旷工次数扣款
                                        kgAmount = kgAmount.add(sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(kgDays)));
                                    } else {
                                        //按照基本工资的百分比扣款

                                        kgAmount = kgAmount.add(new BigDecimal(kgDays).multiply(new BigDecimal(systemAttendanceTeam.getAbsenteeAmount())));
                                    }
                                }
                                systemColumnTenants = systemColumnTenantMapper.selectList(new LambdaQueryWrapper<SystemColumnTenant>() {{
                                    isNotNull(SystemColumnTenant::getGenceId);
                                    eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                                }});
                                for (SystemColumnTenant systemColumnTenant : systemColumnTenants) {
                                    //来区分通过 天还是小时请的假
                                    List<SystemColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).collect(Collectors.toList());
                                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).count();
//                                    //计算每个小时薪资是多少
//                                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
//                                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
//                                        last("limit 1");
//                                    }});
//                                    if (ObjectUtils.isEmpty(dingClassTeam)) {
//
//                                        continue;
//                                    }
//                                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
//                                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
//                                    }});
//                                    //当前班次每天上多久班
//                                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                                    vacationHour = vacationHour.add(new BigDecimal(8).multiply(vacationDay));
                                    //时薪是多少
                                    BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).divide(new BigDecimal(8), 2, RoundingMode.HALF_UP);
                                    SystemFalseDiligence dingFalseDiligence = systemFalseDiligenceMapper.selectById(systemColumnTenant.getGenceId());
                                    switch (dingFalseDiligence.getLeaveRulesType()) {
                                        case 1:
                                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                                            break;
                                        case 2:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                                            break;
                                        case 3:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                                            break;
                                    }
                                }

//                                yfAmount = yfAmount.subtract(kgAmount);
//                                sfAmount = sfAmount.subtract(kgAmount);

                            } else {
                                //十五号及十五号前转正
                                //转正后最后一次的调薪
                                HrmSalaryFixed zzhHrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
//                                    le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                                    eq(HrmSalaryFixed::getIsEffect, 1);
                                    orderByDesc(HrmSalaryFixed::getDate);
                                    last("limit 1");
                                }});
                                if (ObjectUtils.isEmpty(zzhHrmSalaryFixed)) {
                                    sfAmount = sfAmount.add(BigDecimal.ZERO);
                                    yfAmount = yfAmount.add(BigDecimal.ZERO);
                                } else {
                                    List<HrmSalaryFixedTable> zzhhrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                                        eq(HrmSalaryFixedTable::getFixedId, zzhHrmSalaryFixed.getId());
                                    }});
                                    for (HrmSalaryFixedTable hrmSalaryFixedTable : zzhhrmSalaryFixedTableList) {
                                        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                                        if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                                            continue;
                                        }
                                        HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                                        hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                                        hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                                        hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
                                        hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                                        hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                                        sfAmount = sfAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                                        yfAmount = yfAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                                    }
                                }
//                                    if (formalPeriodAnswerRequired2 != formalPeriodAttendanceRequired2) {
//                                        if (sfAmount.compareTo(BigDecimal.ZERO) != 0) {
//                                            sfAmount = sfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                            yfAmount = yfAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
//                                        }
//                                    }
                                systemColumnTenants = systemColumnTenantMapper.selectList(new LambdaQueryWrapper<SystemColumnTenant>() {{
                                    isNotNull(SystemColumnTenant::getGenceId);
                                    eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                                }});
                                for (SystemColumnTenant systemColumnTenant : systemColumnTenants) {
                                    //来区分通过 天还是小时请的假
                                    List<SystemColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).collect(Collectors.toList());
                                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                                    Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).count();
//                                    //计算每个小时薪资是多少
//                                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
//                                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
//                                        last("limit 1");
//                                    }});
//                                    if (ObjectUtils.isEmpty(dingClassTeam)) {
//
//                                        continue;
//                                    }
//                                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
//                                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
//                                    }});
//                                    //当前班次每天上多久班
//                                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                                    vacationHour = vacationHour.add(new BigDecimal(8).multiply(vacationDay));
                                    //时薪是多少
                                    BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).divide(new BigDecimal(8), 2, RoundingMode.HALF_UP);
                                    SystemFalseDiligence dingFalseDiligence = systemFalseDiligenceMapper.selectById(systemColumnTenant.getGenceId());
                                    switch (dingFalseDiligence.getLeaveRulesType()) {
                                        case 1:
                                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                                            break;
                                        case 2:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                                            break;
                                        case 3:
                                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                                            break;
                                    }
                                }
                                if (kgDays != 0) {
                                    if (systemAttendanceTeam.getAbsenteeRulesType() == 1) {
                                        //按照旷工次数扣款
                                        kgAmount = kgAmount.add(sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(kgDays)));
                                    } else {
                                        kgAmount = kgAmount.add(new BigDecimal(kgDays).multiply(new BigDecimal(systemAttendanceTeam.getAbsenteeAmount())));
                                        //按照基本工资的百分比扣款

                                    }
                                }
//                                yfAmount = yfAmount.subtract(kgAmount);
//                                sfAmount = sfAmount.subtract(kgAmount);
                            }
                            break;
                    }
                    break;
            }

        } else if (employeeDO.getRegularizationTime() == null) {
            if (hrmSalaryPlan.getMonthlySalaryStandard() == 1) {
                List<SystemColumnValue> trialPeriodDingColumnValues = systemColumnValueMapper.selectList(new LambdaQueryWrapper<SystemColumnValue>() {{
                    eq(SystemColumnValue::getDate, workDateFrame);
//            lt(SystemColumnValue::getDate, monthEnd + " 00:00:00");
                    eq(SystemColumnValue::getDingUserId, employeeDO.getId());
                }});
                //试用期薪资
                HrmSalaryFixed hrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
//                    le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                    eq(HrmSalaryFixed::getIsEffect, 1);
                    orderByDesc(HrmSalaryFixed::getDate);
                    last("limit 1");
                }});
                //计算薪资合计
                List<HrmSalaryFixedTable> hrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                    eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed.getId());
                }});
                //基本项工资
                BigDecimal syqAmount = BigDecimal.ZERO;
                BigDecimal syJbAmount = BigDecimal.ZERO;
                for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTableList) {
                    HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                    if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                        continue;
                    }
                    HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                    hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeFrontAmount());
                    hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                    hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                    syJbAmount = syJbAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
                }

                //如果应出勤是0那就全额工资 否则就计算基础工资/应出勤天数*实际出勤天数
                if (formalPeriodAnswerRequired2 == 0) {
                    yfAmount = BigDecimal.ZERO;
                    sfAmount = BigDecimal.ZERO;
                } else {
                    //按照上班天数扣款
//                yfAmount = syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_HALF_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
                    yfAmount = syJbAmount;
//                sfAmount = syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_HALF_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
                    sfAmount = syJbAmount;
                }
                //计算旷工
                SystemColumnTenant kgColumn = systemColumnTenantMapper.selectOne(new LambdaQueryWrapper<SystemColumnTenant>() {{
                    eq(SystemColumnTenant::getAlias, "absenteeism_days");
                    eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                }});
                Double hgDays = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == kgColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();

                if (hgDays != 0) {
                    if (systemAttendanceTeam.getAbsenteeRulesType() == 1) {
                        //按照旷工次数扣款
                        kgAmount = kgAmount.add(syJbAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP)).multiply(new BigDecimal(hgDays));
                    } else {
                        //按照基本工资的百分比扣款

                        kgAmount = kgAmount.add(new BigDecimal(hgDays).multiply(new BigDecimal(systemAttendanceTeam.getAbsenteeAmount())));
                    }
                }
            } else {

                List<SystemColumnValue> trialPeriodDingColumnValues = systemColumnValueMapper.selectList(new LambdaQueryWrapper<SystemColumnValue>() {{
                    eq(SystemColumnValue::getDate, workDateFrame);
//            lt(SystemColumnValue::getDate, monthEnd + " 00:00:00");
                    eq(SystemColumnValue::getDingUserId, employeeDO.getId());
                }});
                //试用期薪资
                HrmSalaryFixed hrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
//                    le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                    eq(HrmSalaryFixed::getIsEffect, 1);
                    orderByDesc(HrmSalaryFixed::getDate);
                    last("limit 1");
                }});
                //计算薪资合计
                List<HrmSalaryFixedTable> hrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                    eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed.getId());
                }});
                //基本项工资
                BigDecimal syqAmount = BigDecimal.ZERO;
                BigDecimal syJbAmount = BigDecimal.ZERO;
                for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTableList) {
                    HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                    if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                        continue;
                    }
                    HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                    hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeFrontAmount());
                    hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                    hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                    syJbAmount = syJbAmount.add(hrmSalaryFixedTable.getBecomeFrontAmount());
                }
                //如果应出勤是0那就全额工资 否则就计算基础工资/应出勤天数*实际出勤天数
                if (formalPeriodAnswerRequired2 == 0) {
                } else {
                    //按照上班天数扣款
//                yfAmount = syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_HALF_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
                    yfAmount = syJbAmount;
//                sfAmount = syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_HALF_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
                    sfAmount = syJbAmount;
                }

                List<SystemColumnTenant> systemColumnTenants = systemColumnTenantMapper.selectList(new LambdaQueryWrapper<SystemColumnTenant>() {{
                    isNotNull(SystemColumnTenant::getGenceId);
                    eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                }});
                for (SystemColumnTenant systemColumnTenant : systemColumnTenants) {
                    //来区分通过 天还是小时请的假
                    List<SystemColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).collect(Collectors.toList());
                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                    Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).count();
//                    //计算每个小时薪资是多少
//                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
//                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
//                        last("limit 1");
//                    }});
//                    if (ObjectUtils.isEmpty(dingClassTeam)) {
//
//                        continue;
//                    }
//                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
//                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
//                    }});
//                    //当前班次每天上多久班
//                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                    vacationHour = vacationHour.add(new BigDecimal(8).multiply(vacationDay));
                    //时薪是多少
                    BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).divide(new BigDecimal(8), 2, RoundingMode.HALF_UP);
                    SystemFalseDiligence dingFalseDiligence = systemFalseDiligenceMapper.selectById(systemColumnTenant.getGenceId());
                    switch (dingFalseDiligence.getLeaveRulesType()) {
                        case 1:
                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                            break;
                        case 2:
                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                            break;
                        case 3:
                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                            break;
                    }
                }
                //计算旷工
                SystemColumnTenant kgColumn = systemColumnTenantMapper.selectOne(new LambdaQueryWrapper<SystemColumnTenant>() {{
                    eq(SystemColumnTenant::getAlias, "absenteeism_days");
                    eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                }});
                Double hgDays = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == kgColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();

                if (hgDays != 0) {
                    if (systemAttendanceTeam.getAbsenteeRulesType() == 1) {
                        //按照旷工次数扣款
                        //按照基本工资的百分比扣款
                        kgAmount = kgAmount.add(syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP)).multiply(new BigDecimal(hgDays));
                    } else {
                        kgAmount = kgAmount.add(new BigDecimal(hgDays).multiply(new BigDecimal(systemAttendanceTeam.getAbsenteeAmount())));

                    }
                }
            }

        } else {
            if (hrmSalaryPlan.getMonthlySalaryStandard() == 1) {
                List<SystemColumnValue> trialPeriodDingColumnValues = systemColumnValueMapper.selectList(new LambdaQueryWrapper<SystemColumnValue>() {{
                    eq(SystemColumnValue::getDate, workDateFrame);
//            lt(SystemColumnValue::getDate, monthEnd + " 00:00:00");
                    eq(SystemColumnValue::getDingUserId, employeeDO.getId());
                }});
                //试用期薪资
                HrmSalaryFixed hrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
//                le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                    eq(HrmSalaryFixed::getIsEffect, 1);
                    orderByDesc(HrmSalaryFixed::getDate);
                    last("limit 1");
                }});
                //计算薪资合计
                List<HrmSalaryFixedTable> hrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                    eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed.getId());
                }});
                //基本项工资
                BigDecimal syJbAmount = BigDecimal.ZERO;
                for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTableList) {
                    HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                    if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                        continue;
                    }

                    HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                    hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
                    hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                    hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                    syJbAmount = syJbAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                }
                //如果应出勤是0那就全额工资 否则就计算基础工资/应出勤天数*实际出勤天数
                if (formalPeriodAnswerRequired2 == 0) {
                } else {
                    //按照上班天数扣款
//                yfAmount = syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_HALF_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
                    yfAmount = syJbAmount;
//                sfAmount = syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_HALF_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
                    sfAmount = syJbAmount;
                }

                List<SystemColumnTenant> systemColumnTenants = systemColumnTenantMapper.selectList(new LambdaQueryWrapper<SystemColumnTenant>() {{
                    isNotNull(SystemColumnTenant::getGenceId);
                    eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                }});
                for (SystemColumnTenant systemColumnTenant : systemColumnTenants) {
                    //来区分通过 天还是小时请的假
                    List<SystemColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).collect(Collectors.toList());
                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                    Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).count();
//                    //计算每个小时薪资是多少
//                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
//                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
//                        last("limit 1");
//                    }});
//                    if (ObjectUtils.isEmpty(dingClassTeam)) {
//
//                        continue;
//                    }
//                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
//                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
//                    }});
//                    //当前班次每天上多久班
//                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                    vacationHour = vacationHour.add(new BigDecimal(8).multiply(vacationDay));
                    //时薪是多少
                    BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).divide(new BigDecimal(8), 2, RoundingMode.HALF_UP);
                    SystemFalseDiligence dingFalseDiligence = systemFalseDiligenceMapper.selectById(systemColumnTenant.getGenceId());
                    switch (dingFalseDiligence.getLeaveRulesType()) {
                        case 1:
                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                            break;
                        case 2:
                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                            break;
                        case 3:
                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                            break;
                    }
                }
                //计算旷工
                SystemColumnTenant kgColumn = systemColumnTenantMapper.selectOne(new LambdaQueryWrapper<SystemColumnTenant>() {{
                    eq(SystemColumnTenant::getAlias, "absenteeism_days");
                    eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                }});
                Double hgDays = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == kgColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();

                if (hgDays != 0) {
                    if (systemAttendanceTeam.getAbsenteeRulesType() == 1) {
                        //按照旷工次数扣款
                        kgAmount = kgAmount.add(syJbAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP)).multiply(new BigDecimal(hgDays));

                    } else {
                        kgAmount = kgAmount.add(new BigDecimal(hgDays).multiply(new BigDecimal(systemAttendanceTeam.getAbsenteeAmount())));
                        //按照基本工资的百分比扣款
                    }
                }
            } else {
                List<SystemColumnValue> trialPeriodDingColumnValues = systemColumnValueMapper.selectList(new LambdaQueryWrapper<SystemColumnValue>() {{
                    eq(SystemColumnValue::getDate, workDateFrame);
//            lt(SystemColumnValue::getDate, monthEnd + " 00:00:00");
                    eq(SystemColumnValue::getDingUserId, employeeDO.getId());
                }});
                //试用期薪资
                HrmSalaryFixed hrmSalaryFixed = hrmSalaryFixedMapper.selectOne(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                    eq(HrmSalaryFixed::getEmployeeId, employeeDO.getId());
//                le(HrmSalaryFixed::getDate, regularizationTime + " 00:00:00");
                    eq(HrmSalaryFixed::getIsEffect, 1);
                    orderByDesc(HrmSalaryFixed::getDate);
                    last("limit 1");
                }});
                //计算薪资合计
                List<HrmSalaryFixedTable> hrmSalaryFixedTableList = hrmSalaryFixedTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixedTable>() {{
                    eq(HrmSalaryFixedTable::getFixedId, hrmSalaryFixed.getId());
                }});
                //基本项工资
                BigDecimal syJbAmount = BigDecimal.ZERO;
                for (HrmSalaryFixedTable hrmSalaryFixedTable : hrmSalaryFixedTableList) {
                    HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryFixedTable.getTableId());
                    if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                        continue;
                    }
                    HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
                    hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
                    hrmSalaryRecordEmployeeTable.setValue(hrmSalaryFixedTable.getBecomeAfterAmount());
                    hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
                    syJbAmount = syJbAmount.add(hrmSalaryFixedTable.getBecomeAfterAmount());
                }
                //如果应出勤是0那就全额工资 否则就计算基础工资/应出勤天数*实际出勤天数
                if (formalPeriodAnswerRequired2 == 0) {

                } else {
                    //按照上班天数扣款
//                yfAmount = syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_HALF_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
                    yfAmount = syJbAmount;
//                sfAmount = syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), BigDecimal.ROUND_HALF_UP, 2).multiply(new BigDecimal(formalPeriodAttendanceRequired2));
                    sfAmount = syJbAmount;
                }

                List<SystemColumnTenant> systemColumnTenants = systemColumnTenantMapper.selectList(new LambdaQueryWrapper<SystemColumnTenant>() {{
                    isNotNull(SystemColumnTenant::getGenceId);
                    eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                }});
                for (SystemColumnTenant systemColumnTenant : systemColumnTenants) {
                    //来区分通过 天还是小时请的假
                    List<SystemColumnValue> collect2 = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).collect(Collectors.toList());
                    BigDecimal vacationDay = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 1).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                    BigDecimal vacationHour = BigDecimal.valueOf(collect2.stream().filter(d -> d.getVacationType() == 2).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum());
                    Long count = dingColumnValues.stream().filter(d -> d.getColumnId() == systemColumnTenant.getId()).count();
//                    //计算每个小时薪资是多少
//                    DingClassTeam dingClassTeam = dingClassTeamMapper.selectOne(new LambdaQueryWrapper<DingClassTeam>() {{
//                        eq(DingClassTeam::getTeamId, dingUser.getTeamId());
//                        last("limit 1");
//                    }});
//                    if (ObjectUtils.isEmpty(dingClassTeam)) {
//
//                        continue;
//                    }
//                    DingAttendanceClasses selectByWorkHours = dingAttendanceClassesMapper.selectOne(new LambdaQueryWrapper<DingAttendanceClasses>() {{
//                        eq(DingAttendanceClasses::getId, dingClassTeam.getClassId());
//                    }});
//                    //当前班次每天上多久班
//                    BigDecimal bigDecimal = selectByWorkHours(selectByWorkHours);
                    vacationHour = vacationHour.add(new BigDecimal(8).multiply(vacationDay));
                    //时薪是多少
                    BigDecimal hoursAmount = sfAmount.divide(new BigDecimal(21.75), 2, RoundingMode.HALF_UP).divide(new BigDecimal(8), 2, RoundingMode.HALF_UP);
                    SystemFalseDiligence dingFalseDiligence = systemFalseDiligenceMapper.selectById(systemColumnTenant.getGenceId());
                    switch (dingFalseDiligence.getLeaveRulesType()) {
                        case 1:
                            qjAmount = qjAmount.add(new BigDecimal(count).multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount())));
                            break;
                        case 2:
                            qjAmount = qjAmount.add(hoursAmount.multiply(new BigDecimal(dingFalseDiligence.getLeaveAmount()).divide(new BigDecimal(100))).multiply(vacationHour));
                            break;
                        case 3:
                            qjAmount = qjAmount.add(hoursAmount.multiply(vacationHour));
                            break;
                    }
                }
                //计算旷工
                SystemColumnTenant kgColumn = systemColumnTenantMapper.selectOne(new LambdaQueryWrapper<SystemColumnTenant>() {{
                    eq(SystemColumnTenant::getAlias, "absenteeism_days");
                    eq(SystemColumnTenant::getTenantId, employeeDO.getTenantId());
                }});
                Double hgDays = trialPeriodDingColumnValues.stream().filter(d -> d.getColumnId() == kgColumn.getId()).mapToDouble(d -> Double.parseDouble(d.getColumnValue())).sum();

                if (hgDays != 0) {
                    if (systemAttendanceTeam.getAbsenteeRulesType() == 1) {
                        //按照基本工资的百分比扣款
                        kgAmount = kgAmount.add(syJbAmount.divide(new BigDecimal(formalPeriodAnswerRequired2), 2, RoundingMode.HALF_UP)).multiply(new BigDecimal(hgDays));
                    } else {
                        //按照旷工次数扣款
                        kgAmount = kgAmount.add(new BigDecimal(hgDays).multiply(new BigDecimal(systemAttendanceTeam.getAbsenteeAmount())));
                    }
                }
            }
        }
//        sfAmount = sfAmount.subtract(grsb).subtract(grgjj);
//        yfAmount = yfAmount.subtract(sbAmount).subtract(gjjAmount).subtract(cdAmount).subtract(kgAmount).subtract(ztAmount).subtract(qkAmount).subtract(qjAmount);
//        sfAmount = sfAmount.subtract(cdAmount).subtract(kgAmount).subtract(ztAmount).subtract(qkAmount).subtract(qjAmount);
        List<HrmSalaryTableConfigTenant> allHrmSalaryTableConfigTenants = hrmSalaryTableConfigTenantMapper.selectList(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
            eq(HrmSalaryTableConfigTenant::getIsDisplayed, 1);
            eq(HrmSalaryTableConfigTenant::getStatus, 1);
            ne(HrmSalaryTableConfigTenant::getPid, 0);
            orderByAsc(HrmSalaryTableConfigTenant::getDistinguish);
        }});
        Integer sfAmountId=-1;
        Integer yfAmountId=-1;
        Integer kqhjId=-1;
        BigDecimal kqhjAmount=BigDecimal.ZERO;
        for (int i = 0; i < allHrmSalaryTableConfigTenants.size(); i++) {
            HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(allHrmSalaryTableConfigTenants.get(i).getId());
            if (ObjectUtils.isEmpty(hrmSalaryTableConfigTenant) || hrmSalaryTableConfigTenant.getIsDisplayed() == 0) {
                continue;
            }
            if (hrmSalaryTableConfigTenant.getDistinguish() == 39 || hrmSalaryTableConfigTenant.getDistinguish() == 40 || hrmSalaryTableConfigTenant.getDistinguish() == 41) {
                continue;
            }
            HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = new HrmSalaryRecordEmployeeTable();
            hrmSalaryRecordEmployeeTable.setTableId(hrmSalaryTableConfigTenant.getId());
            hrmSalaryRecordEmployeeTable.setRecordEmployeeId(hrmSalaryRecordEmployee.getId());
            switch (hrmSalaryTableConfigTenant.getDistinguish()) {
                //考勤扣款多少钱暂时手填预留出来
                //迟到扣款
                case 12:
                    hrmSalaryRecordEmployeeTable.setIsConfirm(1);
                    hrmSalaryRecordEmployeeTable.setValue(cdAmount);
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    yfAmount = yfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    sfAmount=sfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    kqhjAmount=kqhjAmount.add(hrmSalaryRecordEmployeeTable.getValue());
                    break;
                //早退扣款
                case 13:
                    hrmSalaryRecordEmployeeTable.setIsConfirm(1);
                    hrmSalaryRecordEmployeeTable.setValue(ztAmount);
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    yfAmount = yfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    sfAmount=sfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    kqhjAmount=kqhjAmount.add(hrmSalaryRecordEmployeeTable.getValue());
                    break;
                //旷工扣款
                case 14:
                    hrmSalaryRecordEmployeeTable.setIsConfirm(1);
                    hrmSalaryRecordEmployeeTable.setValue(kgAmount);
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    yfAmount = yfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    sfAmount=  sfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    kqhjAmount=kqhjAmount.add(hrmSalaryRecordEmployeeTable.getValue());
                    break;
                //假期扣款
                case 15:
                    hrmSalaryRecordEmployeeTable.setIsConfirm(1);
                    hrmSalaryRecordEmployeeTable.setValue(qjAmount);
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    yfAmount = yfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    sfAmount=sfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    kqhjAmount=kqhjAmount.add(hrmSalaryRecordEmployeeTable.getValue());
                    break;
                //缺卡扣款
                case 16:
                    hrmSalaryRecordEmployeeTable.setIsConfirm(1);
                    hrmSalaryRecordEmployeeTable.setValue(qkAmount);
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    yfAmount = yfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    sfAmount=sfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    kqhjAmount=kqhjAmount.add(hrmSalaryRecordEmployeeTable.getValue());
                    break;
                //考勤扣款合计
                case 18:
                    break;
                case 19:
//                    hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                    hrmSalaryRecordEmployeeTable.setValue(yfAmount);
//                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    break;
                case 22:
//                    hrmSalaryRecordEmployeeTable.setIsConfirm(1);
//                    hrmSalaryRecordEmployeeTable.setValue(sfAmount);
//                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    break;
                //个人社保
                case 68:
                    hrmSalaryRecordEmployeeTable.setValue(grsb);
                    hrmSalaryRecordEmployeeTable.setIsConfirm(1);
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    sfAmount=sfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    break;
                //个人公积金
                case 69:
                    hrmSalaryRecordEmployeeTable.setValue(grgjj);
                    hrmSalaryRecordEmployeeTable.setIsConfirm(1);
                    hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                    sfAmount=sfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                    break;
                case 39:
                    break;
                case 40:
                    break;
                case 41:
                    break;
                default:
                    if (hrmSalaryTableConfigTenant.getIsAddSubtract() == 1) {
                        hrmSalaryRecordEmployeeTable.setIsConfirm(1);
                        hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());
                        if(!ObjectUtils.isEmpty(hrmSalaryRecordEmployeeTable.getValue())){
                            sfAmount = sfAmount.add(hrmSalaryRecordEmployeeTable.getValue());
                            yfAmount = yfAmount.add(hrmSalaryRecordEmployeeTable.getValue());
                        }

                    } else if (hrmSalaryTableConfigTenant.getIsAddSubtract() == 2) {
                        hrmSalaryRecordEmployeeTable.setIsConfirm(1);
                        hrmSalaryRecordEmployeeTable.setIsAddSubtract(hrmSalaryTableConfigTenant.getIsAddSubtract());

                        if(!ObjectUtils.isEmpty(hrmSalaryRecordEmployeeTable.getValue())){
                            sfAmount = sfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                            yfAmount = yfAmount.subtract(hrmSalaryRecordEmployeeTable.getValue());
                        }
                    }
            }
            hrmSalaryRecordEmployeeTableMapper.insert(hrmSalaryRecordEmployeeTable);
            if (hrmSalaryTableConfigTenant.getDistinguish() == 22 ) {
                sfAmountId=hrmSalaryRecordEmployeeTable.getId();
            }
            if(hrmSalaryTableConfigTenant.getDistinguish()==19){
                yfAmountId=hrmSalaryRecordEmployeeTable.getId();
            }
            if(hrmSalaryTableConfigTenant.getDistinguish()==18){
                kqhjId=hrmSalaryRecordEmployeeTable.getId();
            }
        }
        if(sfAmountId!=-1){
            HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = hrmSalaryRecordEmployeeTableMapper.selectById(sfAmountId);
            hrmSalaryRecordEmployeeTable.setIsConfirm(1);
            hrmSalaryRecordEmployeeTable.setValue(sfAmount);
            hrmSalaryRecordEmployeeTable.setIsAddSubtract(3);
            hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTable);
        }
        if(yfAmountId!=-1){
            HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = hrmSalaryRecordEmployeeTableMapper.selectById(yfAmountId);
            hrmSalaryRecordEmployeeTable.setIsConfirm(1);
            hrmSalaryRecordEmployeeTable.setValue(yfAmount);
            hrmSalaryRecordEmployeeTable.setIsAddSubtract(3);
            hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTable);
        }

        if(kqhjId!=-1){
            HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = hrmSalaryRecordEmployeeTableMapper.selectById(kqhjId);
            hrmSalaryRecordEmployeeTable.setIsConfirm(1);
            hrmSalaryRecordEmployeeTable.setValue(kqhjAmount);
            hrmSalaryRecordEmployeeTable.setIsAddSubtract(3);
            hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTable);
        }
        return null;

    }





    @Override
    public BigDecimal selectByWorkHours(DingAttendanceClasses dingAttendanceClasses) {
        List<Map<String, String>> restDataList = new ArrayList<>();
        Map<String, String> map1 = new HashMap<>();
        map1.put("startTime", dingAttendanceClasses.getBreakOnDutyOne());
        map1.put("endTime", dingAttendanceClasses.getBreakOffDutyOne());
        restDataList.add(map1);
        Map<String, String> map2 = new HashMap<>();
        map2.put("startTime", dingAttendanceClasses.getBreakOnDutyTwo());
        map2.put("endTime", dingAttendanceClasses.getBreakOffDutyTwo());
        restDataList.add(map2);
        Map<String, String> map3 = new HashMap<>();
        map3.put("startTime", dingAttendanceClasses.getBreakOnDutyThree());
        map3.put("endTime", dingAttendanceClasses.getBreakOffDutyThree());
        restDataList.add(map3);
        BigDecimal restHours = DateUtil.startTimeCompareEndTimeByRestHours(restDataList);
        List<Map<String, String>> workDataList = new ArrayList<>();
        Map<String, String> workData = new HashMap<>();
        workData.put("startTime", dingAttendanceClasses.getOnDuty());
        workData.put("endTime", dingAttendanceClasses.getOffDuty());
        workDataList.add(workData);
        BigDecimal workHours = DateUtil.startTimeCompareEndTimeByWorkHours(workDataList);
        System.err.println("工作时间" + workHours + "休息时间" + restHours);
        return workHours.subtract(restHours);
    }
    @Override
    @DataPermission(enable = false)
    public JSONObject selectRecordListInfo(JSONObject jsonObject) {
        JSONObject result = new JSONObject();
        List<JSONObject> resultList = new ArrayList<>();
        Integer pageNum = jsonObject.getInteger("pageNum");
        Integer pageSize = jsonObject.getInteger("pageSize");
        Integer id = jsonObject.getInteger("id");
        jsonObject.put("recordInfoId", null);
        HrmSalaryRecord hrmSalaryRecord = hrmSalaryRecordMapper.selectById(id);
        HrmSalaryRecordEmployee hrmSalaryRecordEmployee1 = hrmSalaryRecordEmployeeMapper.selectOne(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
            eq(HrmSalaryRecordEmployee::getRecordId, id);
            last("limit 1");
        }});
        List<HrmSalaryRecordEmployeeTable> hrmSalarycolumnRecordEmployeeTables = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
            eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee1.getId());
        }});
        List<JSONObject> columnList = new ArrayList<>();
        JSONObject column = new JSONObject();
        column.put("id", 99991);
        column.put("key", "employeeName");
        column.put("value", "姓名");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99995);
        column.put("key", "employeeNo");
        column.put("value", "工号");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99992);
        column.put("key", "departmentName");
        column.put("value", "部门");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99993);
        column.put("key", "postName");
        column.put("value", "岗位");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99998);
        column.put("key", "employeeNo");
        column.put("value", "职级");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99999);
        column.put("value", "在职状态");
        column.put("99999", "");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99997);
        column.put("key", "employeeNo");
        column.put("value", "聘用形式");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99996);
        column.put("key", "employeeNo");
        column.put("value", "员工状态");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99994);
        column.put("key", "salaryDay");
        column.put("value", "实际计薪天数");
        columnList.add(column);
        for (HrmSalaryRecordEmployeeTable hrmSalarycolumnRecordEmployeeTable : hrmSalarycolumnRecordEmployeeTables) {
            HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalarycolumnRecordEmployeeTable.getTableId());
            column = new JSONObject();
            column.put("id", hrmSalarycolumnRecordEmployeeTable.getTableId());
            column.put("value", hrmSalaryTableConfigTenant.getName());
            columnList.add(column);
        }
        PageHelper.startPage(pageNum, pageSize);
        List<HrmSalaryRecordEmployee> hrmSalaryRecordEmployees = hrmSalaryRecordEmployeeMapper.selectInfoList(jsonObject);
        hrmSalaryRecordEmployees.forEach(hrmSalaryRecordEmployee -> {
            EmployeeDO employeeDO = employeeMapper.selectById(hrmSalaryRecordEmployee.getEmployeeId());
            List<HrmSalaryRecordEmployeeTable> hrmSalaryRecordEmployeeTables = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
                eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee.getId());
            }});
            JSONObject sonValue = new JSONObject();
            sonValue.put("99991", hrmSalaryRecordEmployee.getEmployeeName());
            CommonResult<DeptRespDTO> dept = deptApi.getDept(hrmSalaryRecordEmployee.getDepartmentId().longValue());
            if (!ObjectUtils.isEmpty(dept.getData())) {
                sonValue.put("99992", dept.getData().getName());
            } else {
                sonValue.put("99992", "");
            }
            sonValue.put("id", hrmSalaryRecordEmployee.getId());
            CommonResult<PostRespDTO> post = postApi.getPost(hrmSalaryRecordEmployee.getPostId().longValue());
            if (!ObjectUtils.isEmpty(post.getData())) {
                sonValue.put("99993", post.getData().getName());
            }
            CommonResult<PostLevelRespDTO> postLevelById = postLevelApi.getPostLevelById(employeeDO.getPostLevelId());
            CommonResult<List<DictDataRespDTO>> hrmEmployeeStatus = dictDataApi.getDictDataList("hrm_employee_status");
            CommonResult<List<DictDataRespDTO>> hrmEmploymentForm = dictDataApi.getDictDataList("hrm_employment_form");
            List<DictDataRespDTO> dictDataRespDTOS = hrmEmployeeStatus.getData();
            List<String> collect = dictDataRespDTOS.stream().filter(d -> d.getValue().equals(employeeDO.getState() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
            List<DictDataRespDTO> dictForm = hrmEmploymentForm.getCheckedData();
            List<String> collect1 = dictForm.stream().filter(d -> d.getValue().equals(employeeDO.getEmploymentForm() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
            if (!ObjectUtils.isEmpty(collect)) {
                sonValue.put("99996", collect.get(0));
            } else {
                sonValue.put("99996", "--");
            }
            if (!ObjectUtils.isEmpty(collect1)) {
                sonValue.put("99997", collect1.get(0));
            } else {
                sonValue.put("99997", "--");
            }
            if (!ObjectUtils.isEmpty(postLevelById.getData())) {
                sonValue.put("99998", postLevelById.getData().getName());
            } else {
                sonValue.put("99998", "");
            }
            if (employeeDO.getState() == 6) {
                sonValue.put("99999", "离职");
            } else {
                sonValue.put("99999", "在职");
            }
//            dingColumnMapper.selectOne(new LambdaQueryWrapper<DingColumn>(){{
//
//            }});

            List<DingColumnValue> sbMonthDingColumnValues = dingColumnValueMapper.selectList(new QueryWrapper<DingColumnValue>() {{
                select("if (sum( column_value ) =0,column_value,sum( column_value )) AS columnValue,\n" +
                        "\tcolumn_id columnId  ");
                ge("date", hrmSalaryRecord.getTime() + "-01 00:00:00");
                le("date", hrmSalaryRecord.getTime() + "-31 23:59:59");
                eq("ding_user_id", employeeDO.getDingUserId());
                eq("column_id", 17);
                groupBy("ding_user_id,column_id");
            }});

            if (ObjectUtils.isEmpty(sbMonthDingColumnValues)) {
                List<SystemColumnValue> systemColumnValues = systemColumnValueMapper.selectList(new QueryWrapper<SystemColumnValue>() {{
                    select("if (sum( column_value ) =0,column_value,sum( column_value )) AS columnValue,\n" +
                            "\tcolumn_id columnId  ");
                    eq("date", hrmSalaryRecord.getTime() );
                    eq("ding_user_id", employeeDO.getId());
                    eq("column_id", 17);
                    groupBy("ding_user_id,column_id");
                }});

                if(ObjectUtils.isEmpty(systemColumnValues)){
                    sonValue.put("99994", 0);
                }else {
                    sonValue.put("99994", systemColumnValues.get(0).getColumnValue());
                }


            } else {
                sonValue.put("99994", sbMonthDingColumnValues.get(0).getColumnValue());
            }
            sonValue.put("99995", employeeDO.getEmployeeNo());
            for (HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable : hrmSalaryRecordEmployeeTables) {
                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryRecordEmployeeTable.getTableId());
                sonValue.put("id", hrmSalaryTableConfigTenant.getId());
                if (hrmSalaryRecordEmployeeTable.getValue() == null) {
                    sonValue.put(hrmSalaryTableConfigTenant.getId() + "", "0");
                } else {
                    sonValue.put(hrmSalaryTableConfigTenant.getId() + "", hrmSalaryRecordEmployeeTable.getValue());
                }
            }
            resultList.add(sonValue);
        });
        result.put("column", columnList);
        result.put("resultList", new PageInfo<>(resultList));
        return result;
    }

    @Override
    @DataPermission(enable = false)
    public JSONObject selectRecordUpdateListInfo(JSONObject jsonObject) {
        JSONObject result = new JSONObject();
        List<JSONObject> resultList = new ArrayList<>();
        Integer id = jsonObject.getInteger("id");

        HrmSalaryRecord hrmSalaryRecord = hrmSalaryRecordMapper.selectById(id);

//      jsonObject.put("recordInfoId",id);
        HrmSalaryRecordEmployee hrmSalaryRecordEmployee1 = hrmSalaryRecordEmployeeMapper.selectOne(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
            eq(HrmSalaryRecordEmployee::getRecordId, id);
            last("limit 1");
        }});
        List<HrmSalaryRecordEmployeeTable> hrmSalarycolumnRecordEmployeeTables = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
            eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee1.getId());
        }});
        List<JSONObject> columnList = new ArrayList<>();
        JSONObject column = new JSONObject();
        column.put("id", "a" + 99991);
        column.put("key", "employeeName");
        column.put("isUpdate", 0);
        column.put("value", "姓名");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", "a" + 99992);
        column.put("key", "departmentName");
        column.put("isUpdate", 0);
        column.put("value", "部门");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", "a" + 99993);
        column.put("key", "postName");
        column.put("isUpdate", 0);
        column.put("value", "岗位");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", "a" + 99995);
        column.put("key", "employeeNo");
        column.put("isUpdate", 0);
        column.put("value", "工号");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99998);
        column.put("key", "employeeNo");
        column.put("value", "职级");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99999);
        column.put("value", "在职状态");
        column.put("99999", "");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99997);
        column.put("key", "employeeNo");
        column.put("value", "聘用形式");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99996);
        column.put("key", "employeeNo");
        column.put("value", "员工状态");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", "a" + 99994);
        column.put("key", "salaryDay");
        column.put("isUpdate", 0);
        column.put("value", "实际计薪天数");
        columnList.add(column);
        for (HrmSalaryRecordEmployeeTable hrmSalarycolumnRecordEmployeeTable : hrmSalarycolumnRecordEmployeeTables) {
            HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalarycolumnRecordEmployeeTable.getTableId());
            column = new JSONObject();
            column.put("id", "a" + hrmSalarycolumnRecordEmployeeTable.getTableId());
            column.put("value", hrmSalaryTableConfigTenant.getName());
            column.put("isUpdate", hrmSalaryTableConfigTenant.getIsUpdate());
            columnList.add(column);
        }
        ;
//        PageHelper.startPage(pageNum, pageSize);
        List<HrmSalaryRecordEmployee> hrmSalaryRecordEmployees = hrmSalaryRecordEmployeeMapper.selectInfoList(jsonObject);
        hrmSalaryRecordEmployees.forEach(hrmSalaryRecordEmployee -> {
            EmployeeDO employeeDO = employeeMapper.selectById(hrmSalaryRecordEmployee.getEmployeeId());
            List<HrmSalaryRecordEmployeeTable> hrmSalaryRecordEmployeeTables = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
                eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee.getId());
            }});
            JSONObject sonValue = new JSONObject();
            sonValue.put("a" + "99991", hrmSalaryRecordEmployee.getEmployeeName());
            CommonResult<DeptRespDTO> dept = deptApi.getDept(hrmSalaryRecordEmployee.getDepartmentId().longValue());
            if (!ObjectUtils.isEmpty(dept.getData())) {
                sonValue.put("a" + "99992", dept.getData().getName());
            } else {
                sonValue.put("a" + "99992", "");
            }
            sonValue.put("id", hrmSalaryRecordEmployee.getId());
            CommonResult<PostRespDTO> post = postApi.getPost(hrmSalaryRecordEmployee.getPostId().longValue());
            if (!ObjectUtils.isEmpty(post.getData())) {
                sonValue.put("a" + "99993", post.getData().getName());
            }

            CommonResult<PostLevelRespDTO> postLevelById = postLevelApi.getPostLevelById(employeeDO.getPostLevelId());
            CommonResult<List<DictDataRespDTO>> hrmEmployeeStatus = dictDataApi.getDictDataList("hrm_employee_status");
            CommonResult<List<DictDataRespDTO>> hrmEmploymentForm = dictDataApi.getDictDataList("hrm_employment_form");
            List<DictDataRespDTO> dictDataRespDTOS = hrmEmployeeStatus.getData();
            List<String> collect = dictDataRespDTOS.stream().filter(d -> d.getValue().equals(employeeDO.getState() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
            List<DictDataRespDTO> dictForm = hrmEmploymentForm.getCheckedData();
            List<String> collect1 = dictForm.stream().filter(d -> d.getValue().equals(employeeDO.getEmploymentForm() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
            if (!ObjectUtils.isEmpty(collect)) {
                sonValue.put("99996", collect.get(0));

            } else {
                sonValue.put("99996", "--");
            }
            if (!ObjectUtils.isEmpty(collect1)) {
                sonValue.put("99997", collect1.get(0));
            } else {
                sonValue.put("99997", "--");
            }
            if (!ObjectUtils.isEmpty(postLevelById.getData())) {
                sonValue.put("99998", postLevelById.getData().getName());
            } else {
                sonValue.put("99998", "");
            }
            if (employeeDO.getState() == 6) {
                sonValue.put("99999", "离职");
            } else {
                sonValue.put("99999", "在职");
            }
            List<DingColumnValue> sbMonthDingColumnValues = dingColumnValueMapper.selectList(new QueryWrapper<DingColumnValue>() {{
                select("if (sum( column_value ) =0,column_value,sum( column_value )) AS columnValue,\n" +
                        "\tcolumn_id columnId  ");
                ge("date", hrmSalaryRecord.getTime() + "-01 00:00:00");
                le("date", hrmSalaryRecord.getTime() + "-31 23:59:59");
                eq("ding_user_id", employeeDO.getDingUserId());
                eq("column_id", 17);
                groupBy("ding_user_id,column_id");
            }});

            if (ObjectUtils.isEmpty(sbMonthDingColumnValues) || ObjectUtils.isEmpty(sbMonthDingColumnValues.get(0))) {

                sonValue.put("a" + "99994", 0);
            } else {
                sonValue.put("a" + "99994", sbMonthDingColumnValues.get(0).getColumnValue());
            }

            sonValue.put("a" + "99995", employeeDO.getEmployeeNo());
            sonValue.put("id", hrmSalaryRecordEmployee.getId());
            for (HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable : hrmSalaryRecordEmployeeTables) {
                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryRecordEmployeeTable.getTableId());

                if (hrmSalaryRecordEmployeeTable.getValue() == null) {
                    sonValue.put("a" + hrmSalaryTableConfigTenant.getId() + "", "0");
                } else {
                    sonValue.put("a" + hrmSalaryTableConfigTenant.getId() + "", hrmSalaryRecordEmployeeTable.getValue());
                }
            }
            resultList.add(sonValue);
        });
        result.put("column", columnList);
        result.put("resultList", resultList);
        return result;
    }

    @Override
    @DataPermission(enable = false)
    public JSONObject selectRecordUpdateListInfoBYDA(JSONObject jsonObject) {
        JSONObject result = new JSONObject();
        List<JSONObject> resultList = new ArrayList<>();
        Integer id = jsonObject.getInteger("id");
        HrmSalaryRecordEmployee hrmSalaryRecordEmployee1 = hrmSalaryRecordEmployeeMapper.selectOne(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
            eq(HrmSalaryRecordEmployee::getId, id);
            last("limit 1");
        }});
        HrmSalaryRecord hrmSalaryRecord = hrmSalaryRecordMapper.selectById(hrmSalaryRecordEmployee1.getRecordId());
        jsonObject.put("recordInfoId", id);
        List<HrmSalaryRecordEmployeeTable> hrmSalarycolumnRecordEmployeeTables = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
            eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee1.getId());
        }});
        List<JSONObject> columnList = new ArrayList<>();
        JSONObject column = new JSONObject();
        column.put("id", "a" + 99991);
        column.put("key", "employeeName");
        column.put("isUpdate", 0);
        column.put("value", "姓名");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", "a" + 99992);
        column.put("key", "departmentName");
        column.put("isUpdate", 0);
        column.put("value", "部门");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", "a" + 99993);
        column.put("key", "postName");
        column.put("isUpdate", 0);
        column.put("value", "岗位");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", "a" + 99995);
        column.put("key", "employeeNo");
        column.put("isUpdate", 0);
        column.put("value", "工号");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99998);
        column.put("key", "employeeNo");
        column.put("value", "职级");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99999);
        column.put("value", "在职状态");
        column.put("99999", "");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99997);
        column.put("key", "employeeNo");
        column.put("value", "聘用形式");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99996);
        column.put("key", "employeeNo");
        column.put("value", "员工状态");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", "a" + 99994);
        column.put("key", "salaryDay");
        column.put("isUpdate", 0);
        column.put("value", "实际计薪天数");
        columnList.add(column);
        for (HrmSalaryRecordEmployeeTable hrmSalarycolumnRecordEmployeeTable : hrmSalarycolumnRecordEmployeeTables) {
            HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalarycolumnRecordEmployeeTable.getTableId());
            column = new JSONObject();
            column.put("id", "a" + hrmSalarycolumnRecordEmployeeTable.getTableId());
            column.put("value", hrmSalaryTableConfigTenant.getName());
            column.put("isUpdate", hrmSalaryTableConfigTenant.getIsUpdate());
            columnList.add(column);
        }
//      PageHelper.startPage(pageNum, pageSize);
        List<HrmSalaryRecordEmployee> hrmSalaryRecordEmployees = hrmSalaryRecordEmployeeMapper.selectInfoList(jsonObject);
        hrmSalaryRecordEmployees.forEach(hrmSalaryRecordEmployee -> {
            EmployeeDO employeeDO = employeeMapper.selectById(hrmSalaryRecordEmployee.getEmployeeId());
            List<HrmSalaryRecordEmployeeTable> hrmSalaryRecordEmployeeTables = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
                eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee.getId());
            }});
            JSONObject sonValue = new JSONObject();
            sonValue.put("a" + "99991", hrmSalaryRecordEmployee.getEmployeeName());
            CommonResult<DeptRespDTO> dept = deptApi.getDept(hrmSalaryRecordEmployee.getDepartmentId().longValue());
            if (!ObjectUtils.isEmpty(dept.getData())) {
                sonValue.put("a" + "99992", dept.getData().getName());
            } else {
                sonValue.put("a" + "99992", "");
            }
            sonValue.put("id", hrmSalaryRecordEmployee.getId());
            CommonResult<PostRespDTO> post = postApi.getPost(hrmSalaryRecordEmployee.getPostId().longValue());
            if (!ObjectUtils.isEmpty(post.getData())) {
                sonValue.put("a" + "99993", post.getData().getName());
            }

            CommonResult<PostLevelRespDTO> postLevelById = postLevelApi.getPostLevelById(employeeDO.getPostLevelId());
            CommonResult<List<DictDataRespDTO>> hrmEmployeeStatus = dictDataApi.getDictDataList("hrm_employee_status");
            CommonResult<List<DictDataRespDTO>> hrmEmploymentForm = dictDataApi.getDictDataList("hrm_employment_form");
            List<DictDataRespDTO> dictDataRespDTOS = hrmEmployeeStatus.getData();
            List<String> collect = dictDataRespDTOS.stream().filter(d -> d.getValue().equals(employeeDO.getState() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
            List<DictDataRespDTO> dictForm = hrmEmploymentForm.getCheckedData();
            List<String> collect1 = dictForm.stream().filter(d -> d.getValue().equals(employeeDO.getEmploymentForm() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
            if (!ObjectUtils.isEmpty(collect)) {
                sonValue.put("99996", collect.get(0));
            } else {
                sonValue.put("99996", "--");
            }
            if (!ObjectUtils.isEmpty(collect1)) {
                sonValue.put("99997", collect1.get(0));
            } else {
                sonValue.put("99997", "--");
            }
            if (!ObjectUtils.isEmpty(postLevelById.getData())) {
                sonValue.put("99998", postLevelById.getData().getName());
            } else {
                sonValue.put("99998", "");
            }
            if (employeeDO.getState() == 6) {
                sonValue.put("99999", "离职");
            } else {
                sonValue.put("99999", "在职");
            }
            List<DingColumnValue> sbMonthDingColumnValues = dingColumnValueMapper.selectList(new QueryWrapper<DingColumnValue>() {{
                select("if (sum( column_value ) =0,column_value,sum( column_value )) AS columnValue,\n" +
                        "\tcolumn_id columnId  ");
                ge("date", hrmSalaryRecord.getCreatTime() + "-01 00:00:00");
                le("date", hrmSalaryRecord.getCreatTime() + "-31 23:59:59");
                eq("ding_user_id", employeeDO.getDingUserId());
                eq("column_id", 17);
                groupBy("ding_user_id,column_id");
            }});
            if (ObjectUtils.isEmpty(sbMonthDingColumnValues) || ObjectUtils.isEmpty(sbMonthDingColumnValues.get(0))) {
                sonValue.put("a" + "99994", 0);
            } else {
                sonValue.put("a" + "99994", sbMonthDingColumnValues.get(0).getColumnValue());
            }
            sonValue.put("a" + "99995", employeeDO.getEmployeeNo());
            sonValue.put("id", hrmSalaryRecordEmployee.getId());
            for (HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable : hrmSalaryRecordEmployeeTables) {
                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryRecordEmployeeTable.getTableId());
                if (hrmSalaryRecordEmployeeTable.getValue() == null) {
                    sonValue.put("a" + hrmSalaryTableConfigTenant.getId() + "", "0");
                } else {
                    sonValue.put("a" + hrmSalaryTableConfigTenant.getId() + "", hrmSalaryRecordEmployeeTable.getValue());
                }
            }
            resultList.add(sonValue);
        });
        result.put("column", columnList);
        result.put("resultList", resultList);
        return result;
    }

    @Override
    public List<JSONObject> selectRecordList(JSONObject param) {
        String date = param.getString("date");
        Integer state = param.getInteger("state");
        List<Integer> createBy = param.getList("createBy", Integer.class);
        String createTimeStart = param.getString("createTimeStart");
        String createTimeEnd = param.getString("createTimeEnd");
        List<JSONObject> resultList = new ArrayList<>();
        List<HrmSalaryRecord> hrmSalaryRecords = hrmSalaryRecordMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecord>() {{
            ge(HrmSalaryRecord::getCreatTime, date + "-01");
            le(HrmSalaryRecord::getCreatTime, date + "-12");
            in(HrmSalaryRecord::getStatus, 0, 1, 2, 3);
            in(!ObjectUtils.isEmpty(state), HrmSalaryRecord::getStatus, state);
            ge(!ObjectUtils.isEmpty(createTimeStart), HrmSalaryRecord::getTime, createTimeStart);
            le(!ObjectUtils.isEmpty(createTimeEnd), HrmSalaryRecord::getTime, createTimeEnd);
            in(!ObjectUtils.isEmpty(createBy), HrmSalaryRecord::getEmployeeId, createBy);
            orderByDesc(HrmSalaryRecord::getId);
        }});
        hrmSalaryRecords.forEach(hrmSalaryRecord -> {
            EmployeeDO employeeDO = employeeMapper.selectById(hrmSalaryRecord.getEmployeeId());
            Long sendStatus = hrmSalaryRecordEmployeeMapper.selectCount(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
                eq(HrmSalaryRecordEmployee::getSendStatus, 1);
                eq(HrmSalaryRecordEmployee::getRecordId, hrmSalaryRecord.getId());
            }});
            Long checkStatus = hrmSalaryRecordEmployeeMapper.selectCount(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
                eq(HrmSalaryRecordEmployee::getCheckStatus, 1);
                eq(HrmSalaryRecordEmployee::getRecordId, hrmSalaryRecord.getId());
            }});
            Long confirmStatus = hrmSalaryRecordEmployeeMapper.selectCount(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
                eq(HrmSalaryRecordEmployee::getConfirmStatus, 1);
                eq(HrmSalaryRecordEmployee::getRecordId, hrmSalaryRecord.getId());
            }});
            Long allNum = hrmSalaryRecordEmployeeMapper.selectCount(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
                eq(HrmSalaryRecordEmployee::getRecordId, hrmSalaryRecord.getId());
            }});
            JSONObject result = new JSONObject();
            result.put("id", hrmSalaryRecord.getId());
            result.put("allNum", allNum);
            if (!ObjectUtils.isEmpty(employeeDO)) {
                result.put("employeeName", employeeDO.getName());
            }
            result.put("creatTime", hrmSalaryRecord.getCreatTime());
            result.put("sendStatus", sendStatus);
            result.put("checkStatus", checkStatus);
            result.put("confirmStatus", confirmStatus);
            result.put("startTime", hrmSalaryRecord.getCreatTime() + "-01");
            result.put("endTime", hrmSalaryRecord.getCreatTime() + "-31");
            result.put("time", hrmSalaryRecord.getTime());
            result.put("status", hrmSalaryRecord.getStatus());
            resultList.add(result);
        });
        return resultList;
    }

    @Override
    public List<JSONObject> updateRecordInfo(JSONObject jsonObject) {
        JSONArray jsonObjectList = jsonObject.getJSONArray("resultList");
        for (Object js : jsonObjectList) {
            JSONObject data = JSONObject.parseObject(JSONObject.toJSONString(js));
            BigDecimal sf = BigDecimal.ZERO;
            BigDecimal yf = BigDecimal.ZERO;
            BigDecimal kqKK = BigDecimal.ZERO;
            Integer id = data.getInteger("id");
            HrmSalaryRecordEmployee hrmSalaryRecordEmployee = hrmSalaryRecordEmployeeMapper.selectById(id);
            hrmSalaryRecordEmployee.setCheckStatus(0);
            hrmSalaryRecordEmployee.setConfirmStatus(0);
            hrmSalaryRecordEmployeeMapper.updateById(hrmSalaryRecordEmployee);
            List<HrmSalaryRecordEmployeeTable> hrmSalaryRecordEmployeeTables = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
                eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, id);
            }});
            for (HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable : hrmSalaryRecordEmployeeTables) {
                BigDecimal decimal = data.getBigDecimal("a" + hrmSalaryRecordEmployeeTable.getTableId() + "");
//                hrmSalaryRecordEmployeeTable.setValue(decimal);
                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryRecordEmployeeTable.getTableId());
                BigDecimal b = decimal.subtract(hrmSalaryRecordEmployeeTable.getValue());

                switch (hrmSalaryTableConfigTenant.getDistinguish()) {
                    //考勤扣款多少钱暂时手填预留出来
                    case 12:
                        kqKK = kqKK.add(decimal);
                        sf = sf.subtract(b);
                        hrmSalaryRecordEmployeeTable.setValue(decimal);
                        hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTable);
                        break;
                    case 13:
                        kqKK = kqKK.add(decimal);
                        sf = sf.subtract(b);
                        hrmSalaryRecordEmployeeTable.setValue(decimal);
                        hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTable);
                        break;
                    case 14:
                        kqKK = kqKK.add(decimal);
                        sf = sf.subtract(b);
                        hrmSalaryRecordEmployeeTable.setValue(decimal);
                        hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTable);
                        break;
                    case 15:
                        kqKK = kqKK.add(decimal);
                        sf = sf.subtract(b);
                        hrmSalaryRecordEmployeeTable.setValue(decimal);
                        hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTable);
                        break;
                    case 16:
                        kqKK = kqKK.add(decimal);
                        sf = sf.subtract(b);
                        hrmSalaryRecordEmployeeTable.setValue(decimal);
                        hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTable);
                        break;
                    case 21:
                        sf = sf.subtract(b);
                        yf = yf.subtract(b);

                        hrmSalaryRecordEmployeeTable.setValue(decimal);
                        hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTable);
                        break;
                    default:
                        if (hrmSalaryTableConfigTenant.getIsAddSubtract() == 1) {
                            yf = yf.add(b);
                            sf = sf.add(b);
                        } else if (hrmSalaryTableConfigTenant.getIsAddSubtract() == 2) {
                            sf = sf.subtract(b);
                            yf = yf.subtract(b);
                        }
                        hrmSalaryRecordEmployeeTable.setValue(decimal);
                        hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTable);
                }
                hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTable);
            }
            HrmSalaryTableConfigTenant hrmSalaryTableConfigTenantYF = hrmSalaryTableConfigTenantMapper.selectOne(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
                eq(HrmSalaryTableConfigTenant::getDistinguish, 19);
            }});
            HrmSalaryTableConfigTenant hrmSalaryTableConfigTenantKQKK = hrmSalaryTableConfigTenantMapper.selectOne(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
                eq(HrmSalaryTableConfigTenant::getDistinguish, 18);
            }});
            HrmSalaryTableConfigTenant hrmSalaryTableConfigTenantSF = hrmSalaryTableConfigTenantMapper.selectOne(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
                eq(HrmSalaryTableConfigTenant::getDistinguish, 22);
            }});
            HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTableYF = hrmSalaryRecordEmployeeTableMapper.selectOne(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
                eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee.getId());
                eq(HrmSalaryRecordEmployeeTable::getTableId, hrmSalaryTableConfigTenantYF.getId());
                last("limit 1");
            }});
            hrmSalaryRecordEmployeeTableYF.setValue(hrmSalaryRecordEmployeeTableYF.getValue().add(yf));
            hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTableYF);
            HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTableSF = hrmSalaryRecordEmployeeTableMapper.selectOne(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
                eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee.getId());
                eq(HrmSalaryRecordEmployeeTable::getTableId, hrmSalaryTableConfigTenantSF.getId());
                last("limit 1");
            }});
            hrmSalaryRecordEmployeeTableSF.setValue(hrmSalaryRecordEmployeeTableSF.getValue().add(sf));
            hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTableSF);
            HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTableKQKK = hrmSalaryRecordEmployeeTableMapper.selectOne(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
                eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee.getId());
                eq(HrmSalaryRecordEmployeeTable::getTableId, hrmSalaryTableConfigTenantKQKK.getId());
                last("limit 1");
            }});
            hrmSalaryRecordEmployeeTableKQKK.setValue(kqKK);
            hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTableKQKK);
        }
        return Collections.emptyList();
    }

    @Override
    @DataPermission(enable = false)
    public JSONObject selectConfirmTable(Integer id) {
        JSONObject result = new JSONObject();
        List<JSONObject> tableList = new ArrayList<>();
        HrmSalaryRecord hrmSalaryRecord = hrmSalaryRecordMapper.selectById(id);
        HrmSalaryRecordEmployee hrmSalaryRecordEmployee1 = hrmSalaryRecordEmployeeMapper.selectOne(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
            eq(HrmSalaryRecordEmployee::getRecordId, id);
            last("limit 1");
        }});
        List<HrmSalaryRecordEmployeeTable> hrmSalarycolumnRecordEmployeeTables = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
            eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee1.getId());
        }});
        for (HrmSalaryRecordEmployeeTable hrmSalarycolumnRecordEmployeeTable : hrmSalarycolumnRecordEmployeeTables) {
            HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalarycolumnRecordEmployeeTable.getTableId());
            JSONObject table = new JSONObject();
            table.put("tableName", hrmSalaryTableConfigTenant.getName());
            table.put("id", hrmSalaryTableConfigTenant.getId());
            table.put("isConfirm", hrmSalarycolumnRecordEmployeeTable.getIsConfirm());
            tableList.add(table);
        }
        result.put("id", hrmSalaryRecord.getId());
        result.put("name", hrmSalaryRecord.getName());
        result.put("prompt", hrmSalaryRecord.getPrompt());
        result.put("isPrompt", hrmSalaryRecord.getIsPrompt());
        result.put("tableList", tableList);
        return result;
    }

    @Override
    @DataPermission(enable = false)
    public Integer updateConfirm(JSONObject jsonObject) {
        jsonObject = jsonObject.getJSONObject("date");
        Integer recordId = jsonObject.getInteger("id");
        String prompt = jsonObject.getString("prompt");
        Integer isPrompt = jsonObject.getInteger("isPrompt");
        String name = jsonObject.getString("name");
        HrmSalaryRecord hrmSalaryRecord = hrmSalaryRecordMapper.selectById(recordId);
        hrmSalaryRecord.setIsPrompt(isPrompt);
        hrmSalaryRecord.setName(name);
        hrmSalaryRecord.setPrompt(prompt);
        hrmSalaryRecord.setStatus(9);
        hrmSalaryRecord.setUpdateTime(LocalDateTime.now());
        hrmSalaryRecord.setUpdater("todo");
        hrmSalaryRecordMapper.updateById(hrmSalaryRecord);
        List<Integer> collect = hrmSalaryRecordEmployeeMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
            eq(HrmSalaryRecordEmployee::getRecordId, recordId);
        }}).stream().map(HrmSalaryRecordEmployee::getId).collect(Collectors.toList());
        JSONArray jsonObjectList = jsonObject.getJSONArray("tableList");
        for (Object js : jsonObjectList) {
            JSONObject data = JSONObject.parseObject(JSONObject.toJSONString(js));
            Integer id = data.getInteger("id");
            Integer isConfirm = data.getInteger("isConfirm");
            List<HrmSalaryRecordEmployeeTable> hrmSalaryRecordEmployeeTables = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
                in(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, collect);
                eq(HrmSalaryRecordEmployeeTable::getTableId, id);
            }});
            for (HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable : hrmSalaryRecordEmployeeTables) {
                hrmSalaryRecordEmployeeTable.setIsConfirm(isConfirm);
                hrmSalaryRecordEmployeeTableMapper.updateById(hrmSalaryRecordEmployeeTable);
            }
        }
        return 0;
    }

    @Override

    public List<JSONObject> selectConfirmRecordListInfo(JSONObject param) {

        String date = param.getString("date");
        Integer state = param.getInteger("state");
        List<Integer> createBy = param.getList("createBy", Integer.class);
        String createTimeStart = param.getString("createTimeStart");
        String createTimeEnd = param.getString("createTimeEnd");
        List<JSONObject> resultList = new ArrayList<>();
        List<HrmSalaryRecord> hrmSalaryRecords = hrmSalaryRecordMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecord>() {{
            ge(HrmSalaryRecord::getCreatTime, date + "-01");
            le(HrmSalaryRecord::getCreatTime, date + "-12");
            in(HrmSalaryRecord::getStatus, 9);
            in(!ObjectUtils.isEmpty(state), HrmSalaryRecord::getStatus, state);
            ge(!ObjectUtils.isEmpty(createTimeStart), HrmSalaryRecord::getTime, createTimeStart);
            le(!ObjectUtils.isEmpty(createTimeEnd), HrmSalaryRecord::getTime, createTimeEnd);
            in(!ObjectUtils.isEmpty(createBy), HrmSalaryRecord::getEmployeeId, createBy);
        }});
        hrmSalaryRecords.forEach(hrmSalaryRecord -> {
            EmployeeDO employeeDO = employeeMapper.selectById(hrmSalaryRecord.getEmployeeId());
            Long sendNum = hrmSalaryRecordEmployeeMapper.selectCount(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
                eq(HrmSalaryRecordEmployee::getSendStatus, 1);
                eq(HrmSalaryRecordEmployee::getRecordId, hrmSalaryRecord.getId());
            }});
            Long checkNum = hrmSalaryRecordEmployeeMapper.selectCount(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
                eq(HrmSalaryRecordEmployee::getCheckStatus, 1);
                eq(HrmSalaryRecordEmployee::getRecordId, hrmSalaryRecord.getId());
            }});
            Long confirmNum = hrmSalaryRecordEmployeeMapper.selectCount(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
                eq(HrmSalaryRecordEmployee::getConfirmStatus, 1);
                eq(HrmSalaryRecordEmployee::getRecordId, hrmSalaryRecord.getId());
            }});
            Long allNum = hrmSalaryRecordEmployeeMapper.selectCount(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
                eq(HrmSalaryRecordEmployee::getRecordId, hrmSalaryRecord.getId());
            }});
            JSONObject result = new JSONObject();
            result.put("id", hrmSalaryRecord.getId());
            result.put("allNum", allNum);
            if (ObjectUtils.isEmpty(employeeDO)) {
                result.put("employeeName", "");
            } else {
                result.put("employeeName", employeeDO.getName());
            }
            result.put("createTime", hrmSalaryRecord.getCreatTime());
            result.put("sendNum", sendNum);
            result.put("checkNum", checkNum);
            result.put("confirmNum", confirmNum);
            result.put("startTime", hrmSalaryRecord.getCreatTime() + "-01");
            result.put("endTime", hrmSalaryRecord.getCreatTime() + "-31");
            result.put("time", hrmSalaryRecord.getTime());
            result.put("status", hrmSalaryRecord.getStatus());
            resultList.add(result);
        });
        return resultList;
    }

    @Override
    public JSONObject selectConfirmInfoList(JSONObject param) {
        List<Integer> sxEmployeeIds = new ArrayList<>();
        JSONObject jsonObject = new JSONObject();
        String employeeName = param.getString("employeeName");
        List<Long> employeeIds = param.getList("employeeIds", Long.class);
        Integer sendStatus = param.getInteger("sendStatus");
        Integer checkStatus = param.getInteger("checkStatus");
        Integer confirmStatus = param.getInteger("confirmStatus");
        Integer integer = param.getInteger("recordId");
        Integer pageNum = param.getInteger("pageNum");
        Integer pageSize = param.getInteger("pageSize");
        Integer postLevelId = param.getInteger("postLevelId");
        Integer employeeFrom = param.getInteger("employeeFrom");
        Integer employeeState = param.getInteger("employeeState");
        Integer employeeResignation = param.getInteger("employeeResignation");
        //有无反馈状态 0/无反馈  1/有反馈
        Integer problemFeedbackStatus = param.getInteger("problemFeedbackStatus");
        List<Integer> departmentIds = param.getList("departmentIds", Integer.class);
        List<EmployeeDO> employeeDOS = employeeMapper.selectList(new LambdaQueryWrapper<EmployeeDO>() {{
            eq(!ObjectUtils.isEmpty(postLevelId), EmployeeDO::getPostLevelId, postLevelId);
            eq(!ObjectUtils.isEmpty(employeeFrom), EmployeeDO::getEmploymentForm, employeeFrom);
            eq(!ObjectUtils.isEmpty(employeeState), EmployeeDO::getState, employeeState);
            eq(!ObjectUtils.isEmpty(employeeResignation) && employeeResignation == 2, EmployeeDO::getState, 6);
            ne(!ObjectUtils.isEmpty(employeeResignation) && employeeResignation == 1, EmployeeDO::getState, 6);
            in(!ObjectUtils.isEmpty(departmentIds), EmployeeDO::getDeptId, departmentIds);
        }});

        if (ObjectUtils.isEmpty(employeeDOS)) {
            sxEmployeeIds.add(-1);
        } else {
            sxEmployeeIds = employeeDOS.stream().map(e -> e.getId().intValue()).collect(Collectors.toList());
        }
        Long notSendNum = hrmSalaryRecordEmployeeMapper.selectCount(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
            in(HrmSalaryRecordEmployee::getSendStatus, 0, 2);
            eq(HrmSalaryRecordEmployee::getRecordId, integer);
        }});
        Long notWithdrawNum = hrmSalaryRecordEmployeeMapper.selectCount(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
            eq(HrmSalaryRecordEmployee::getSendStatus, 1);
            eq(HrmSalaryRecordEmployee::getRecordId, integer);
        }});
        Long allNum = hrmSalaryRecordEmployeeMapper.selectCount(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
            eq(HrmSalaryRecordEmployee::getRecordId, integer);
        }});
        if (notSendNum == 0) {
            jsonObject.put("notSendState", 0);
        } else {
            jsonObject.put("notSendState", 1);
        }
        if (notWithdrawNum == 0) {
            jsonObject.put("notWithdrawState", 0);
        } else {
            jsonObject.put("notWithdrawState", 1);
        }

        List<JSONObject> resultList = new ArrayList<>();

        Long sendNum = hrmSalaryRecordEmployeeMapper.selectCount(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
            eq(HrmSalaryRecordEmployee::getSendStatus, 1);
            eq(HrmSalaryRecordEmployee::getRecordId, integer);
        }});
        Long checkNum = hrmSalaryRecordEmployeeMapper.selectCount(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
            eq(HrmSalaryRecordEmployee::getCheckStatus, 0);
            eq(HrmSalaryRecordEmployee::getRecordId, integer);
        }});
        Long confirmNum = hrmSalaryRecordEmployeeMapper.selectCount(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
            eq(HrmSalaryRecordEmployee::getConfirmStatus, 0);
            eq(HrmSalaryRecordEmployee::getRecordId, integer);
        }});
        PageHelper.startPage(pageNum, pageSize);
        List<Integer> finalSxEmployeeIds = sxEmployeeIds;
        List<HrmSalaryRecordEmployee> hrmSalaryRecordEmployees = hrmSalaryRecordEmployeeMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
            eq(HrmSalaryRecordEmployee::getRecordId, integer);
            eq(!ObjectUtils.isEmpty(employeeName), HrmSalaryRecordEmployee::getEmployeeName, employeeName);
            eq(!ObjectUtils.isEmpty(sendStatus), HrmSalaryRecordEmployee::getSendStatus, sendStatus);
            eq(!ObjectUtils.isEmpty(checkStatus), HrmSalaryRecordEmployee::getCheckStatus, checkStatus);
            eq(!ObjectUtils.isEmpty(confirmStatus), HrmSalaryRecordEmployee::getConfirmStatus, confirmStatus);
            in(!ObjectUtils.isEmpty(employeeIds), HrmSalaryRecordEmployee::getEmployeeId, employeeIds);
            in(!ObjectUtils.isEmpty(finalSxEmployeeIds), HrmSalaryRecordEmployee::getEmployeeId, finalSxEmployeeIds);
            isNull(null != problemFeedbackStatus && problemFeedbackStatus == 0,HrmSalaryRecordEmployee::getProblemFeedback);
            isNotNull(null != problemFeedbackStatus && problemFeedbackStatus == 1,HrmSalaryRecordEmployee::getProblemFeedback);
        }});
        jsonObject.put("sendNum", sendNum);
        jsonObject.put("checkNum", checkNum);
        jsonObject.put("confirmNum", confirmNum);
        jsonObject.put("allNum", allNum);
        jsonObject.put("resultList", new PageInfo<>());
        for (HrmSalaryRecordEmployee hrmSalaryRecordEmployee : hrmSalaryRecordEmployees) {
            CommonResult<PostRespDTO> post = postApi.getPost(hrmSalaryRecordEmployee.getPostId().longValue());
            EmployeeDO employeeDO = employeeMapper.selectById(hrmSalaryRecordEmployee.getEmployeeId());
            CommonResult<List<DictDataRespDTO>> hrmEmployeeStatus = dictDataApi.getDictDataList("hrm_employee_status");
            CommonResult<List<DictDataRespDTO>> hrmEmploymentForm = dictDataApi.getDictDataList("hrm_employment_form");
            CommonResult<PostLevelRespDTO> postLevelById = postLevelApi.getPostLevelById(employeeDO.getPostLevelId());
            List<DictDataRespDTO> dictDataRespDTOS = hrmEmployeeStatus.getData();
            List<DictDataRespDTO> dictForm = hrmEmploymentForm.getCheckedData();
            List<String> collect = dictDataRespDTOS.stream().filter(d -> d.getValue().equals(employeeDO.getState() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
            List<String> collect1 = dictForm.stream().filter(d -> d.getValue().equals(employeeDO.getEmploymentForm() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
            JSONObject result = new JSONObject();
            result.put("id", hrmSalaryRecordEmployee.getId());
            result.put("employeeName", employeeDO.getName());
            result.put("employeeNo", employeeDO.getEmployeeNo());
            if (!ObjectUtils.isEmpty(collect)) {
                result.put("employeeStatus", collect.get(0));
            } else {
                result.put("employeeStatus", "");
            }
            if (!ObjectUtils.isEmpty(collect1)) {
                result.put("employeeFrom", collect1.get(0));
            } else {
                result.put("employeeFrom", "");
            }
            if (!ObjectUtils.isEmpty(postLevelById.getData())) {
                result.put("postLevel", postLevelById.getData().getName());
            } else {
                result.put("postLevel", "");
            }

            if (!ObjectUtils.isEmpty(post.getData())) {
                result.put("postName", post.getData().getName());
            } else {
                result.put("postName", "");
            }
            CommonResult<DeptRespDTO> dept = deptApi.getDept(hrmSalaryRecordEmployee.getDepartmentId().longValue());
            if (!ObjectUtils.isEmpty(dept.getData())) {
                result.put("departmentName", dept.getData().getName());
            } else {
                result.put("departmentName", "");
            }
            result.put("sendStatus", hrmSalaryRecordEmployee.getSendStatus());
            result.put("checkStatus", hrmSalaryRecordEmployee.getCheckStatus());
            result.put("confirmStatus", hrmSalaryRecordEmployee.getConfirmStatus());
            result.put("problemFeedback", hrmSalaryRecordEmployee.getProblemFeedback());
            if (employeeDO.getState() == 6) {
                result.put("employeeResignation", "离职");
                result.put("isDimission", 1);
            } else {
                result.put("employeeResignation", "在职");
                result.put("isDimission", 0);
            }
            if (!ObjectUtils.isEmpty(postLevelById.getData())) {
                result.put("postLevel", postLevelById.getData().getName());
            } else {
                result.put("postLevel", "");
            }
            resultList.add(result);
            jsonObject.put("resultList", new PageInfo<>(resultList));
        }
        return jsonObject;
    }

    @Override
    @DataPermission(enable = false)
    public PageInfo selectByConfirmPage(Integer employeeId, Integer pageNum, Integer pageSize) {

        EmployeeDO employeeDO = employeeMapper.selectOne(new LambdaQueryWrapper<EmployeeDO>() {{
            eq(EmployeeDO::getUserId, employeeId);
        }});
        PageHelper.startPage(pageNum, pageSize);
        List<HrmSalaryRecordEmployee> hrmSalaryRecordEmployees = hrmSalaryRecordEmployeeMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
            in(HrmSalaryRecordEmployee::getEmployeeId, employeeDO.getId());
            eq(HrmSalaryRecordEmployee::getSendStatus, 1);
        }});
        hrmSalaryRecordEmployees.forEach(hrmSalaryRecordEmployee -> {
            HrmSalaryRecord hrmSalaryRecord = hrmSalaryRecordMapper.selectById(hrmSalaryRecordEmployee.getRecordId());
            hrmSalaryRecordEmployee.setMonth(hrmSalaryRecord.getTime());
            hrmSalaryRecordEmployee.setTitle(hrmSalaryRecord.getName());
        });


        return new PageInfo<>(hrmSalaryRecordEmployees);
    }

    @Override
    public Integer sendConfirm(Integer ids) {
        HrmSalaryRecordEmployee hrmSalaryRecordEmployees = hrmSalaryRecordEmployeeMapper.selectById(ids);
        if (!ObjectUtils.isEmpty(hrmSalaryRecordEmployees)) {
            hrmSalaryRecordEmployees.setSendStatus(1);
            hrmSalaryRecordEmployees.setProblemFeedback(" ");
            hrmSalaryRecordEmployeeMapper.updateById(hrmSalaryRecordEmployees);
        }
        return 0;
    }

    @Override
    public Integer withdraw(Integer ids) {
        HrmSalaryRecordEmployee hrmSalaryRecordEmployees = hrmSalaryRecordEmployeeMapper.selectById(ids);
        if (!ObjectUtils.isEmpty(hrmSalaryRecordEmployees)) {
            hrmSalaryRecordEmployees.setCheckStatus(0);
            hrmSalaryRecordEmployees.setConfirmStatus(0);
            hrmSalaryRecordEmployees.setSendStatus(2);
            hrmSalaryRecordEmployeeMapper.updateById(hrmSalaryRecordEmployees);
        }
        return 0;
    }

    @Override
    public Integer allSendConfirm(Integer recordId) {

        List<HrmSalaryRecordEmployee> hrmSalaryRecordEmployees = hrmSalaryRecordEmployeeMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
            eq(HrmSalaryRecordEmployee::getRecordId, recordId);
        }});
        if (!ObjectUtils.isEmpty(hrmSalaryRecordEmployees)) {
            for (HrmSalaryRecordEmployee hrmSalaryRecordEmployee : hrmSalaryRecordEmployees) {
                hrmSalaryRecordEmployee.setSendStatus(1);
                hrmSalaryRecordEmployee.setProblemFeedback(" ");
                hrmSalaryRecordEmployeeMapper.updateById(hrmSalaryRecordEmployee);
            }
        }
        return 0;
    }


    @Override
    public Integer allWithdraw(Integer recordId) {
        List<HrmSalaryRecordEmployee> hrmSalaryRecordEmployees = hrmSalaryRecordEmployeeMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
            eq(HrmSalaryRecordEmployee::getRecordId, recordId);
        }});
        if (!ObjectUtils.isEmpty(hrmSalaryRecordEmployees)) {
            for (HrmSalaryRecordEmployee hrmSalaryRecordEmployee : hrmSalaryRecordEmployees) {
                hrmSalaryRecordEmployee.setSendStatus(2);
                hrmSalaryRecordEmployeeMapper.updateById(hrmSalaryRecordEmployee);
            }
        }
        return 0;
    }


    @Override
    public JSONObject selectEmployeeConfirmInfo(Integer id) {
        BigDecimal amountSum = BigDecimal.ZERO;
        JSONObject resultObject = new JSONObject();
        List<JSONObject> resultList = new ArrayList<>();

        HrmSalaryRecordEmployee hrmSalaryRecordEmployee = hrmSalaryRecordEmployeeMapper.selectById(id);
        List<HrmSalaryRecordEmployeeTable> hrmSalaryRecordEmployeeTables = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
            eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee.getId());
            eq(HrmSalaryRecordEmployeeTable::getIsConfirm, 1);
        }});
        List<HrmSalaryTableConfigTenant> hrmSalaryTableConfigTenant1 = hrmSalaryTableConfigTenantMapper.selectList(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
            in(HrmSalaryTableConfigTenant::getId, hrmSalaryRecordEmployeeTables.stream().map(HrmSalaryRecordEmployeeTable::getTableId).collect(Collectors.toList()));
            orderByAsc(HrmSalaryTableConfigTenant::getTableOrder);
        }});
        List<JSONObject> jsonObjectList = new ArrayList<>();
        for (HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant : hrmSalaryTableConfigTenant1) {
            HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable = hrmSalaryRecordEmployeeTableMapper.selectOne(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
                eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee.getId());
                eq(HrmSalaryRecordEmployeeTable::getIsConfirm, 1);
                eq(HrmSalaryRecordEmployeeTable::getTableId, hrmSalaryTableConfigTenant.getId());

            }});
            JSONObject result = new JSONObject();
            result.put("name", hrmSalaryTableConfigTenant.getName());
            result.put("value", hrmSalaryRecordEmployeeTable.getValue());
            result.put("parentId", hrmSalaryTableConfigTenant.getPid());
            result.put("order", hrmSalaryTableConfigTenant.getTableOrder());
            if (hrmSalaryTableConfigTenant.getDistinguish() == 22) {
                amountSum = amountSum.add(hrmSalaryRecordEmployeeTable.getValue());
            }
            jsonObjectList.add(result);
        }
        Map<Integer, List<JSONObject>> parentId = jsonObjectList.stream().collect(Collectors.groupingBy(jsonObject -> jsonObject.getInteger("parentId"), HashMap::new, Collectors.toList()));
        for (Map.Entry<Integer, List<JSONObject>> integerListEntry : parentId.entrySet()) {
            JSONObject jsonObject = new JSONObject();
            Integer key = integerListEntry.getKey();
            HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(key);
            jsonObject.put("name", hrmSalaryTableConfigTenant.getName());
            jsonObject.put("value", integerListEntry.getValue());
            jsonObject.put("order", hrmSalaryTableConfigTenant.getTableOrder());
            resultList.add(jsonObject);
        }
        Collections.sort(resultList, (a, b) -> {
            return a.getInteger("order") - b.getInteger("order");
        });

        resultObject.put("value", resultList);
        resultObject.put("amountSum", amountSum);
        return resultObject;
    }

    @Override
    public List<JSONObject> historySalaryList(String date) {
        List<JSONObject> resultList = new ArrayList<>();
        List<HrmSalaryRecord> hrmSalaryRecords = hrmSalaryRecordMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecord>() {{
            ge(HrmSalaryRecord::getCreatTime, date + "-01");
            le(HrmSalaryRecord::getCreatTime, date + "-12");
            eq(HrmSalaryRecord::getStatus, 6);
        }});
        hrmSalaryRecords.forEach(hrmSalaryRecord -> {
            BigDecimal yfAmount = BigDecimal.ZERO;
            BigDecimal sfAmount = BigDecimal.ZERO;
            BigDecimal gsAmount = BigDecimal.ZERO;
            Long allNum = hrmSalaryRecordEmployeeMapper.selectCount(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
                eq(HrmSalaryRecordEmployee::getRecordId, hrmSalaryRecord.getId());
            }});
            List<Integer> collect = hrmSalaryRecordEmployeeMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
                eq(HrmSalaryRecordEmployee::getRecordId, hrmSalaryRecord.getId());
            }}).stream().map(HrmSalaryRecordEmployee::getId).collect(Collectors.toList());
            final EmployeeDO[] employeeDO = {new EmployeeDO()};
            DataPermissionUtils.executeIgnore(() -> {
                employeeDO[0] = employeeMapper.selectById(hrmSalaryRecord.getEmployeeId());
            });
            HrmSalaryTableConfigTenant hrmSalaryTableConfigTenantss = hrmSalaryTableConfigTenantMapper.selectOne(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
                eq(HrmSalaryTableConfigTenant::getDistinguish, 22);
            }});
            HrmSalaryTableConfigTenant hrmSalaryTableConfigTenantys = hrmSalaryTableConfigTenantMapper.selectOne(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
                eq(HrmSalaryTableConfigTenant::getDistinguish, 19);
            }});
            HrmSalaryTableConfigTenant hrmSalaryTableConfigTenantgs = hrmSalaryTableConfigTenantMapper.selectOne(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
                eq(HrmSalaryTableConfigTenant::getDistinguish, 21);
            }});

            List<HrmSalaryRecordEmployeeTable> hrmSalaryRecordEmployeeTabless = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
                in(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, collect);
                eq(HrmSalaryRecordEmployeeTable::getTableId, hrmSalaryTableConfigTenantss.getId());
            }});
            List<HrmSalaryRecordEmployeeTable> hrmSalaryRecordEmployeeTableys = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
                in(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, collect);
                eq(HrmSalaryRecordEmployeeTable::getTableId, hrmSalaryTableConfigTenantys.getId());
            }});
            List<HrmSalaryRecordEmployeeTable> hrmSalaryRecordEmployeeTablegs = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
                in(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, collect);
                eq(HrmSalaryRecordEmployeeTable::getTableId, hrmSalaryTableConfigTenantgs.getId());
            }});
            if (!ObjectUtils.isEmpty(hrmSalaryRecordEmployeeTabless)) {
                yfAmount = yfAmount.add(hrmSalaryRecordEmployeeTabless.stream().map(a -> a.getValue()).reduce(BigDecimal.ZERO, BigDecimal::add));
            }
            if (!ObjectUtils.isEmpty(hrmSalaryRecordEmployeeTableys)) {
                sfAmount = sfAmount.add(hrmSalaryRecordEmployeeTableys.stream().map(a -> a.getValue()).reduce(BigDecimal.ZERO, BigDecimal::add));
            }
            if (!ObjectUtils.isEmpty(hrmSalaryRecordEmployeeTablegs)) {
                gsAmount = gsAmount.add(hrmSalaryRecordEmployeeTablegs.stream().map(a -> a.getValue()).reduce(BigDecimal.ZERO, BigDecimal::add));
            }
            JSONObject result = new JSONObject();
            result.put("id", hrmSalaryRecord.getId());
            result.put("employeeName", employeeDO[0].getName());
            result.put("createTime", hrmSalaryRecord.getCreatTime());
            result.put("startTime", hrmSalaryRecord.getCreatTime() + "-01");
            result.put("endTime", hrmSalaryRecord.getCreatTime() + "-31");
            result.put("time", hrmSalaryRecord.getTime());
            result.put("status", hrmSalaryRecord.getStatus());
            result.put("allNum", allNum);
            result.put("yfAmount", yfAmount);
            result.put("sfAmount", sfAmount);
            result.put("gsAmount", gsAmount);
            result.put("name", hrmSalaryRecord.getName());
            resultList.add(result);
        });
        return resultList;
    }

    @Override
    @DataPermission(enable = false)
    public JSONObject historySalaryInfo(JSONObject jsonObject) {
        JSONObject result = new JSONObject();
        List<JSONObject> resultList = new ArrayList<>();
        Integer pageNum = jsonObject.getInteger("pageNum");
        Integer pageSize = jsonObject.getInteger("pageSize");
        Integer id = jsonObject.getInteger("id");
        jsonObject.put("recordInfoId", null);
        HrmSalaryRecord hrmSalaryRecord = hrmSalaryRecordMapper.selectById(id);
        HrmSalaryRecordEmployee hrmSalaryRecordEmployee1 = hrmSalaryRecordEmployeeMapper.selectOne(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
            eq(HrmSalaryRecordEmployee::getRecordId, id);
            last("limit 1");
        }});
        List<Integer> collect = hrmSalaryRecordEmployeeMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
            eq(HrmSalaryRecordEmployee::getRecordId, hrmSalaryRecord.getId());
        }}).stream().map(HrmSalaryRecordEmployee::getId).collect(Collectors.toList());
        BigDecimal yfAmount = BigDecimal.ZERO;
        BigDecimal sfAmount = BigDecimal.ZERO;
        BigDecimal gsAmount = BigDecimal.ZERO;
//        BigDecimal sbAmount=BigDecimal.ZERO;
//        BigDecimal gjjAmount=BigDecimal.ZERO;
//        BigDecimal gsSbAmount=BigDecimal.ZERO;
//        BigDecimal gsgjjAmount=BigDecimal.ZERO;
        Long allNum = hrmSalaryRecordEmployeeMapper.selectCount(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
            eq(HrmSalaryRecordEmployee::getRecordId, hrmSalaryRecord.getId());
        }});
        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenantss = hrmSalaryTableConfigTenantMapper.selectOne(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
            eq(HrmSalaryTableConfigTenant::getDistinguish, 22);
        }});
        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenantys = hrmSalaryTableConfigTenantMapper.selectOne(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
            eq(HrmSalaryTableConfigTenant::getDistinguish, 19);
        }});
        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenantgs = hrmSalaryTableConfigTenantMapper.selectOne(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
            eq(HrmSalaryTableConfigTenant::getDistinguish, 21);
        }});

//        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenantsb = hrmSalaryTableConfigTenantMapper.selectOne(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
//            eq(HrmSalaryTableConfigTenant::getDistinguish, 68);
//        }});
//        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenantgjj = hrmSalaryTableConfigTenantMapper.selectOne(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
//            eq(HrmSalaryTableConfigTenant::getDistinguish, 69);
//        }});
//        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenantggssb = hrmSalaryTableConfigTenantMapper.selectOne(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
//            eq(HrmSalaryTableConfigTenant::getDistinguish, 71);
//        }});
//
//        HrmSalaryTableConfigTenant hrmSalaryTableConfigTenantggsgjj = hrmSalaryTableConfigTenantMapper.selectOne(new LambdaQueryWrapper<HrmSalaryTableConfigTenant>() {{
//            eq(HrmSalaryTableConfigTenant::getDistinguish, 73);
//        }});

        List<HrmSalaryRecordEmployeeTable> hrmSalaryRecordEmployeeTabless = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
            in(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, collect);
            eq(HrmSalaryRecordEmployeeTable::getTableId, hrmSalaryTableConfigTenantss.getId());
        }});
        List<HrmSalaryRecordEmployeeTable> hrmSalaryRecordEmployeeTableys = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
            in(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, collect);
            eq(HrmSalaryRecordEmployeeTable::getTableId, hrmSalaryTableConfigTenantys.getId());
        }});
        List<HrmSalaryRecordEmployeeTable> hrmSalaryRecordEmployeeTablegs = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
            in(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, collect);
            eq(HrmSalaryRecordEmployeeTable::getTableId, hrmSalaryTableConfigTenantgs.getId());
        }});

//        List<HrmSalaryRecordEmployeeTable> hrmSalaryRecordEmployeeTablesb = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
//            in(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, collect);
//            eq(HrmSalaryRecordEmployeeTable::getTableId,hrmSalaryTableConfigTenantsb.getId());
//        }});
//
//        List<HrmSalaryRecordEmployeeTable> hrmSalaryRecordEmployeeTablegjj = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
//            in(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, collect);
//            eq(HrmSalaryRecordEmployeeTable::getTableId,hrmSalaryTableConfigTenantgjj.getId());
//        }});
//
//        List<HrmSalaryRecordEmployeeTable> hrmSalaryRecordEmployeeTableggssb = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
//            in(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, collect);
//            eq(HrmSalaryRecordEmployeeTable::getTableId,hrmSalaryTableConfigTenantggssb.getId());
//        }});
//
//        List<HrmSalaryRecordEmployeeTable> hrmSalaryRecordEmployeeTablegsgjj = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
//            in(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, collect);
//            eq(HrmSalaryRecordEmployeeTable::getTableId,hrmSalaryTableConfigTenantggsgjj.getId());
//        }});
        if (!ObjectUtils.isEmpty(hrmSalaryRecordEmployeeTabless)) {
            yfAmount = yfAmount.add(hrmSalaryRecordEmployeeTabless.stream().map(a -> a.getValue()).reduce(BigDecimal.ZERO, BigDecimal::add));
        }
        if (!ObjectUtils.isEmpty(hrmSalaryRecordEmployeeTableys)) {
            sfAmount = sfAmount.add(hrmSalaryRecordEmployeeTableys.stream().map(a -> a.getValue()).reduce(BigDecimal.ZERO, BigDecimal::add));
        }
        if (!ObjectUtils.isEmpty(hrmSalaryRecordEmployeeTablegs)) {
            gsAmount = gsAmount.add(hrmSalaryRecordEmployeeTablegs.stream().map(a -> a.getValue()).reduce(BigDecimal.ZERO, BigDecimal::add));
        }

//        if(!ObjectUtils.isEmpty(hrmSalaryRecordEmployeeTablesb)){
//            sbAmount=sbAmount.add(hrmSalaryRecordEmployeeTablesb.stream().map(a->a.getValue()).reduce(BigDecimal.ZERO,BigDecimal::add));
//        }
//
//        if(!ObjectUtils.isEmpty(hrmSalaryRecordEmployeeTablegjj)){
//            gjjAmount=gjjAmount.add(hrmSalaryRecordEmployeeTablegjj.stream().map(a->a.getValue()).reduce(BigDecimal.ZERO,BigDecimal::add));
//        }
//
//        if(!ObjectUtils.isEmpty(hrmSalaryRecordEmployeeTableggssb)){
//            gsSbAmount=gsSbAmount.add(hrmSalaryRecordEmployeeTableggssb.stream().map(a->a.getValue()).reduce(BigDecimal.ZERO,BigDecimal::add));
//        }
//
//        if(!ObjectUtils.isEmpty(hrmSalaryRecordEmployeeTablegsgjj)){
//            gsgjjAmount=gsgjjAmount.add(hrmSalaryRecordEmployeeTablegsgjj.stream().map(a->a.getValue()).reduce(BigDecimal.ZERO,BigDecimal::add));
//        }
        result.put("yfAmount", yfAmount);
        result.put("sfAmount", sfAmount);
        result.put("gsAmount", gsAmount);
//        result.put("sbAmount",sbAmount);
//        result.put("gjjAmount",gjjAmount);
//        result.put("gsSbAmount",gsSbAmount);
//        result.put("gsgjjAmount",gsgjjAmount);
        result.put("allNum", allNum);


        List<HrmSalaryRecordEmployeeTable> hrmSalarycolumnRecordEmployeeTables = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
            eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee1.getId());
        }});
        List<JSONObject> columnList = new ArrayList<>();
        JSONObject column = new JSONObject();
        column.put("id", 99991);
        column.put("key", "employeeName");
        column.put("value", "姓名");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99992);
        column.put("key", "departmentName");
        column.put("value", "部门");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99993);
        column.put("key", "postName");
        column.put("value", "岗位");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99994);
        column.put("key", "salaryDay");
        column.put("value", "实际计薪天数");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99995);
        column.put("key", "employeeNo");
        column.put("value", "工号");
        columnList.add(column);
        for (HrmSalaryRecordEmployeeTable hrmSalarycolumnRecordEmployeeTable : hrmSalarycolumnRecordEmployeeTables) {
            HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalarycolumnRecordEmployeeTable.getTableId());
            column = new JSONObject();
            column.put("id", hrmSalarycolumnRecordEmployeeTable.getTableId());
            column.put("value", hrmSalaryTableConfigTenant.getName());
            columnList.add(column);
        }
        column = new JSONObject();
        column.put("id", 99996);
        column.put("value", "发送状态");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99997);
        column.put("value", "查看状态");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99998);
        column.put("value", "确认状态");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99999);
        column.put("value", "问题反馈");
        columnList.add(column);
        column = new JSONObject();
        column.put("id", 99910);
        column.put("value", "备注");
        columnList.add(column);
        PageHelper.startPage(pageNum, pageSize);
        List<HrmSalaryRecordEmployee> hrmSalaryRecordEmployees = hrmSalaryRecordEmployeeMapper.selectInfoList(jsonObject);
        hrmSalaryRecordEmployees.forEach(hrmSalaryRecordEmployee -> {
            EmployeeDO employeeDO = employeeMapper.selectById(hrmSalaryRecordEmployee.getEmployeeId());
            List<HrmSalaryRecordEmployeeTable> hrmSalaryRecordEmployeeTables = hrmSalaryRecordEmployeeTableMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
                eq(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, hrmSalaryRecordEmployee.getId());
            }});
            JSONObject sonValue = new JSONObject();
            sonValue.put("99991", hrmSalaryRecordEmployee.getEmployeeName());
            CommonResult<DeptRespDTO> dept = deptApi.getDept(hrmSalaryRecordEmployee.getDepartmentId().longValue());
            if (!ObjectUtils.isEmpty(dept.getData())) {
                sonValue.put("99992", dept.getData().getName());
            } else {
                sonValue.put("99992", "");
            }
            sonValue.put("id", hrmSalaryRecordEmployee.getId());
            CommonResult<PostRespDTO> post = postApi.getPost(hrmSalaryRecordEmployee.getPostId().longValue());
            if (!ObjectUtils.isEmpty(post.getData())) {
                sonValue.put("99993", post.getData().getName());
            }
            List<DingColumnValue> sbMonthDingColumnValues = dingColumnValueMapper.selectList(new QueryWrapper<DingColumnValue>() {{
                select("if (sum( column_value ) =0,column_value,sum( column_value )) AS columnValue,\n" +
                        "\tcolumn_id columnId  ");
                ge("date", hrmSalaryRecord.getCreatTime() + "-01 00:00:00");
                le("date", hrmSalaryRecord.getCreatTime() + "-31 23:59:59");
                eq("ding_user_id", employeeDO.getDingUserId());
                eq("column_id", 17);
                groupBy("ding_user_id,column_id");
            }});
            sonValue.put("99994", sbMonthDingColumnValues.get(0).getColumnValue());
            sonValue.put("99995", employeeDO.getEmployeeNo());
            for (HrmSalaryRecordEmployeeTable hrmSalaryRecordEmployeeTable : hrmSalaryRecordEmployeeTables) {
                HrmSalaryTableConfigTenant hrmSalaryTableConfigTenant = hrmSalaryTableConfigTenantMapper.selectById(hrmSalaryRecordEmployeeTable.getTableId());
                sonValue.put("id", hrmSalaryRecordEmployee.getId());
                if (hrmSalaryRecordEmployeeTable.getValue() == null) {
                    sonValue.put(hrmSalaryTableConfigTenant.getId() + "", "0");
                } else {
                    sonValue.put(hrmSalaryTableConfigTenant.getId() + "", hrmSalaryRecordEmployeeTable.getValue());
                }
            }
            sonValue.put("99996", hrmSalaryRecordEmployee.getSendStatus());
            sonValue.put("99997", hrmSalaryRecordEmployee.getCheckStatus());
            sonValue.put("99998", hrmSalaryRecordEmployee.getConfirmStatus());
            sonValue.put("99999", hrmSalaryRecordEmployee.getProblemFeedback());
            sonValue.put("99910", hrmSalaryRecordEmployee.getRemark());
            resultList.add(sonValue);
        });
        result.put("column", columnList);
        result.put("resultList", new PageInfo<>(resultList));
        return result;
    }

    @Override
    public Integer updateRemark(String remark, Integer id) {
        HrmSalaryRecordEmployee hrmSalaryRecordEmployee = hrmSalaryRecordEmployeeMapper.selectById(id);
        hrmSalaryRecordEmployee.setRemark(remark);
        hrmSalaryRecordEmployeeMapper.updateById(hrmSalaryRecordEmployee);
        return 0;
    }

    @Override
    @DataPermission(enable = false)
    public Integer removeSalary(Integer recordId) {
        hrmSalaryRecordMapper.deleteById(recordId);
        List<Integer> collect = hrmSalaryRecordEmployeeMapper.selectList(new LambdaQueryWrapper<HrmSalaryRecordEmployee>() {{
            eq(HrmSalaryRecordEmployee::getRecordId, recordId);
        }}).stream().map(HrmSalaryRecordEmployee::getId).collect(Collectors.toList());
        hrmSalaryRecordEmployeeMapper.deleteBatchIds(collect);
        hrmSalaryRecordEmployeeTableMapper.delete(new LambdaQueryWrapper<HrmSalaryRecordEmployeeTable>() {{
            in(HrmSalaryRecordEmployeeTable::getRecordEmployeeId, collect);
        }});
        return 0;
    }

    @Override
    public JSONObject selectList() {
        JSONObject param = new JSONObject();
        Long l1 = employeeMapper.selectCount(new LambdaQueryWrapper<EmployeeDO>() {{
        }});
        Long l2 = employeeMapper.selectCount(new LambdaQueryWrapper<EmployeeDO>() {{
            isNotNull(EmployeeDO::getDingUserId);
        }});
        Long l = hrmSalaryPlanEmployeeMapper.selectCountBYEmployeeId();
        param.put("notSalaryNum", l1 - l);
        param.put("notAttendance", l1 - l2);
        return param;
    }

    @Override
    public Integer confirm(Integer id, Integer status, String message) {
        HrmSalaryRecordEmployee hrmSalaryRecordEmployee = hrmSalaryRecordEmployeeMapper.selectById(id);
        hrmSalaryRecordEmployee.setProblemFeedback(message);
        hrmSalaryRecordEmployee.setConfirmStatus(status);
        hrmSalaryRecordEmployeeMapper.updateById(hrmSalaryRecordEmployee);
        return 0;
    }

    @Override
    public Integer checkStatus(Integer id) {
        HrmSalaryRecordEmployee hrmSalaryRecordEmployee = hrmSalaryRecordEmployeeMapper.selectById(id);
        hrmSalaryRecordEmployee.setCheckStatus(1);
        hrmSalaryRecordEmployeeMapper.updateById(hrmSalaryRecordEmployee);
        return 0;
    }

    @Override
    public List<JSONObject> selectNotSalaryEmployeeList(List<Integer> employeeIds) {
//        List<HrmSalaryPlanEmployee> hrmSalaryPlanEmployeeList = hrmSalaryPlanEmployeeMapper.selectList(new LambdaQueryWrapper<HrmSalaryPlanEmployee>() {{
//            in(HrmSalaryPlanEmployee::getEmployeeId, employeeIds);
//        }});
////        employeeIds.forEach(e -> {
//            hrmSalaryPlanEmployeeList.forEach(hrmSalaryPlanEmployee -> {
//                if (e == hrmSalaryPlanEmployee.getEmployeeId()) {
//                    employeeIds.remove(e);
//                }
//            });
//        });
        List<JSONObject> resultList = new ArrayList<>();
        List<EmployeeDO> employeeDOS = employeeMapper.selectList(new LambdaQueryWrapper<EmployeeDO>() {{
            in(EmployeeDO::getId, employeeIds);
        }});
        for (EmployeeDO employeeDO : employeeDOS) {
            JSONObject result = new JSONObject();
            CommonResult<PostLevelRespDTO> postLevelById = postLevelApi.getPostLevelById(employeeDO.getPostLevelId());
            CommonResult<List<DictDataRespDTO>> hrmEmployeeStatus = dictDataApi.getDictDataList("hrm_employee_status");
            CommonResult<List<DictDataRespDTO>> hrmEmploymentForm = dictDataApi.getDictDataList("hrm_employment_form");
            List<DictDataRespDTO> dictDataRespDTOS = hrmEmployeeStatus.getData();
            List<String> collect = dictDataRespDTOS.stream().filter(d -> d.getValue().equals(employeeDO.getState() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
            List<DictDataRespDTO> dictForm = hrmEmploymentForm.getCheckedData();
            List<String> collect1 = dictForm.stream().filter(d -> d.getValue().equals(employeeDO.getEmploymentForm() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
            CommonResult<PostRespDTO> post = postApi.getPost(employeeDO.getPostId().longValue());
            if (!ObjectUtils.isEmpty(collect)) {
                result.put("employeeStatus", collect.get(0));
            } else {
                result.put("employeeStatus", "");
            }
            if (!ObjectUtils.isEmpty(collect1)) {
                result.put("employeeFrom", collect1.get(0));
            } else {
                result.put("employeeFrom", "");
            }
            if (!ObjectUtils.isEmpty(postLevelById.getData())) {
                result.put("postLevel", postLevelById.getData().getName());
            } else {
                result.put("postLevel", "");
            }
            if (!ObjectUtils.isEmpty(post.getData())) {
                result.put("postName", post.getData().getName());
            } else {
                result.put("postName", "");
            }
            if (employeeDO.getState() == 6) {
                result.put("employeeResignation", "离职");
            } else {
                result.put("employeeResignation", "在职");
            }
            if (!ObjectUtils.isEmpty(postLevelById.getData())) {
                result.put("postLevel", postLevelById.getData().getName());
            } else {
                result.put("postLevel", "");
            }
            CommonResult<AdminUserRespDTO> user = adminUserApi.getUser(employeeDO.getUserId());
            if (!ObjectUtils.isEmpty(user.getData())) {
                result.put("employeeName", user.getData().getNickname());
            }
            result.put("employeeNo", employeeDO.getEmployeeNo());
            CommonResult<DeptRespDTO> dept = deptApi.getDept(employeeDO.getDeptId());
            if (!ObjectUtils.isEmpty(dept.getData())) {
                result.put("deptName", dept.getData().getName());
            }
            result.put("employeeId", employeeDO.getId());
            resultList.add(result);
        }
        return resultList;
    }

    @Override
    public List<JSONObject> selectNotDingTeamEmployeeList(List<Integer> employeeIds) {
        List<DingUser> dingUsers = dingUserMapper.selectList(new LambdaQueryWrapper<DingUser>() {{
            in(DingUser::getId, employeeIds);
        }});
        List<DingUser> dingUserStream = dingUsers.stream().filter(d -> ObjectUtils.isEmpty(d.getTeamId())).collect(Collectors.toList());
//          employeeMapper.selectList(new LambdaQueryWrapper<Emp>())

        List<JSONObject> resultList = new ArrayList<>();
        List<EmployeeDO> employeeDOS = employeeMapper.selectList(new LambdaQueryWrapper<EmployeeDO>() {{
            notIn(EmployeeDO::getUserId, employeeIds.stream().map(Integer::getClass).collect(Collectors.toList()));
        }});
        for (EmployeeDO employeeDO : employeeDOS) {
            JSONObject result = new JSONObject();
            CommonResult<PostLevelRespDTO> postLevelById = postLevelApi.getPostLevelById(employeeDO.getPostLevelId());
            CommonResult<List<DictDataRespDTO>> hrmEmployeeStatus = dictDataApi.getDictDataList("hrm_employee_status");
            CommonResult<List<DictDataRespDTO>> hrmEmploymentForm = dictDataApi.getDictDataList("hrm_employment_form");
            List<DictDataRespDTO> dictDataRespDTOS = hrmEmployeeStatus.getData();
            List<String> collect = dictDataRespDTOS.stream().filter(d -> d.getValue().equals(employeeDO.getState() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
            List<DictDataRespDTO> dictForm = hrmEmploymentForm.getCheckedData();
            List<String> collect1 = dictForm.stream().filter(d -> d.getValue().equals(employeeDO.getEmploymentForm() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
            CommonResult<PostRespDTO> post = postApi.getPost(employeeDO.getPostId().longValue());
            if (!ObjectUtils.isEmpty(collect)) {
                result.put("employeeStatus", collect.get(0));
            } else {
                result.put("employeeStatus", "");
            }
            if (!ObjectUtils.isEmpty(collect1)) {
                result.put("employeeFrom", collect1.get(0));
            } else {
                result.put("employeeFrom", "");
            }
            if (!ObjectUtils.isEmpty(postLevelById.getData())) {
                result.put("postLevel", postLevelById.getData().getName());
            } else {
                result.put("postLevel", "");
            }
            if (!ObjectUtils.isEmpty(post.getData())) {
                result.put("postName", post.getData().getName());
            } else {
                result.put("postName", "");
            }
            if (employeeDO.getState() == 6) {
                result.put("employeeResignation", "离职");
            } else {
                result.put("employeeResignation", "在职");
            }
            if (!ObjectUtils.isEmpty(postLevelById.getData())) {
                result.put("postLevel", postLevelById.getData().getName());
            } else {
                result.put("postLevel", "");
            }
            CommonResult<AdminUserRespDTO> user = adminUserApi.getUser(employeeDO.getUserId());
            if (!ObjectUtils.isEmpty(user.getData())) {
                result.put("employeeName", user.getData().getNickname());
            }
            result.put("employeeNo", employeeDO.getEmployeeNo());
            CommonResult<DeptRespDTO> dept = deptApi.getDept(employeeDO.getDeptId());
            if (!ObjectUtils.isEmpty(dept.getData())) {
                result.put("deptName", dept.getData().getName());
            }
            result.put("employeeId", employeeDO.getId());
            resultList.add(result);
        }

        return resultList;
    }

    @Override
    public List<JSONObject> selectNotDingUserEmployeeIdList() {
        List<JSONObject> resultList = new ArrayList<>();
        List<EmployeeDO> employeeDOS = employeeMapper.selectList(new LambdaQueryWrapper<EmployeeDO>() {{
            isNotNull(EmployeeDO::getDingUserId);
        }});
        for (EmployeeDO employeeDO : employeeDOS) {
            JSONObject result = new JSONObject();
            CommonResult<PostLevelRespDTO> postLevelById = postLevelApi.getPostLevelById(employeeDO.getPostLevelId());
            CommonResult<List<DictDataRespDTO>> hrmEmployeeStatus = dictDataApi.getDictDataList("hrm_employee_status");
            CommonResult<List<DictDataRespDTO>> hrmEmploymentForm = dictDataApi.getDictDataList("hrm_employment_form");
            List<DictDataRespDTO> dictDataRespDTOS = hrmEmployeeStatus.getData();
            List<String> collect = dictDataRespDTOS.stream().filter(d -> d.getValue().equals(employeeDO.getState() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
            List<DictDataRespDTO> dictForm = hrmEmploymentForm.getCheckedData();
            List<String> collect1 = dictForm.stream().filter(d -> d.getValue().equals(employeeDO.getEmploymentForm() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
            CommonResult<PostRespDTO> post = postApi.getPost(employeeDO.getPostId().longValue());
            if (!ObjectUtils.isEmpty(collect)) {
                result.put("employeeStatus", collect.get(0));
            } else {
                result.put("employeeStatus", "");
            }
            if (!ObjectUtils.isEmpty(collect1)) {
                result.put("employeeFrom", collect1.get(0));
            } else {
                result.put("employeeFrom", "");
            }
            if (!ObjectUtils.isEmpty(postLevelById.getData())) {
                result.put("postLevel", postLevelById.getData().getName());
            } else {
                result.put("postLevel", "");
            }

            if (!ObjectUtils.isEmpty(post.getData())) {
                result.put("postName", post.getData().getName());
            } else {
                result.put("postName", "");
            }

            if (employeeDO.getState() == 6) {
                result.put("employeeResignation", "离职");
            } else {
                result.put("employeeResignation", "在职");
            }
            if (!ObjectUtils.isEmpty(postLevelById.getData())) {
                result.put("postLevel", postLevelById.getData().getName());
            } else {
                result.put("postLevel", "");
            }
            result.put("employeeId", employeeDO.getId());
            resultList.add(result);
        }
        return resultList;
    }


    @Override
    public JSONObject selectByNotSalary(List<Integer> employeeIds, String month,Integer isSystem) {
        if(isSystem==1){
            JSONObject param = new JSONObject();
            Long l = hrmSalaryPlanEmployeeMapper.selectCount(new LambdaQueryWrapper<HrmSalaryPlanEmployee>() {{
                in(HrmSalaryPlanEmployee::getEmployeeId, employeeIds);
            }});
            List<HrmSalaryPlanEmployee> hrmSalaryPlanEmployeeList = hrmSalaryPlanEmployeeMapper.selectList(new LambdaQueryWrapper<HrmSalaryPlanEmployee>() {{
                in(HrmSalaryPlanEmployee::getEmployeeId, employeeIds);
            }});
            List<Long> collect = hrmSalaryPlanEmployeeList.stream().map(a -> a.getEmployeeId().longValue()).collect(Collectors.toList());
            List<Integer> collect3 = employeeIds.stream().filter(a -> !collect.contains(a)).collect(Collectors.toList());
            List<EmployeeDO> employeeDOS = employeeMapper.selectList(new LambdaQueryWrapper<EmployeeDO>() {{
                in(EmployeeDO::getUserId, employeeIds);
            }});
            List<HrmSalaryFixed> hrmSalaryFixeds = hrmSalaryFixedMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//            (disHrmSalaryFixed::getEmployeeId);
                in(HrmSalaryFixed::getEmployeeId, employeeDOS.stream().map(e -> e.getId()).collect(Collectors.toList()));
                groupBy(HrmSalaryFixed::getEmployeeId);
            }});

            List<HrmSalaryFixed> hrmSalaryFixedList = hrmSalaryFixedMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                in(HrmSalaryFixed::getEmployeeId, employeeDOS.stream().map(e -> e.getId()).collect(Collectors.toList()));
            }});
            List<Long> collect1 = hrmSalaryFixedList.stream().map(hrmSalaryFixed -> hrmSalaryFixed.getEmployeeId().longValue()).collect(Collectors.toList());
            List<Long>  employeeSystemIds = employeeDOS.stream().map(e -> e.getId()).collect(Collectors.toList());
            Long l1 = dingAttendanceConfirmationMapper.selectCount(new LambdaQueryWrapper<DingAttendanceConfirmation>() {{
                eq(DingAttendanceConfirmation::getStartTime, month + "-01");
                le(DingAttendanceConfirmation::getEndTime, month + "-31");
                in(DingAttendanceConfirmation::getEmployeeId, employeeSystemIds);
            }});


            //不在薪资组人员
            param.put("notSalaryPlan", employeeIds.size() - l);
            param.put("notSalaryPlanEmployeeIds", collect3);
            param.put("notKqSystem",employeeIds.size()-l1);
            List<Long> collect2 = employeeDOS.stream().filter(a -> !collect1.contains(a.getId())).map(a -> a.getUserId()).collect(Collectors.toList());
            //未定薪人员
            param.put("notSalaryFixed", employeeIds.size() - hrmSalaryFixeds.size());
            param.put("notSalaryFixedEmployeeId", collect2);
//            未绑定系统薪资组人员
//            param.put("notDingUserNum", employeeNotDingUserIdList.size());
//            param.put("notDingUserId", employeeNotDingUserIdList);
//            //没有考勤组人员
//            param.put("notAttendanceTeam", dingUserStream.size());
//            核算薪资月考勤有异常人员
            return param;
        }else {
            List<EmployeeDO> employeeDOS = employeeMapper.selectList(new LambdaQueryWrapper<EmployeeDO>() {{
                in(EmployeeDO::getUserId, employeeIds);
            }});
            List<Long>  employeeSystemIds = employeeDOS.stream().map(e -> e.getId()).collect(Collectors.toList());
            Long l1 = dingAttendanceConfirmationMapper.selectCount(new LambdaQueryWrapper<DingAttendanceConfirmation>() {{
                eq(DingAttendanceConfirmation::getStartTime, month + "-01");
                le(DingAttendanceConfirmation::getEndTime, month + "-31");
                in(DingAttendanceConfirmation::getEmployeeId, employeeIds);
            }});
            JSONObject param = new JSONObject();
            Long l = hrmSalaryPlanEmployeeMapper.selectCount(new LambdaQueryWrapper<HrmSalaryPlanEmployee>() {{
                in(HrmSalaryPlanEmployee::getEmployeeId, employeeIds);
            }});
            List<HrmSalaryPlanEmployee> hrmSalaryPlanEmployeeList = hrmSalaryPlanEmployeeMapper.selectList(new LambdaQueryWrapper<HrmSalaryPlanEmployee>() {{
                in(HrmSalaryPlanEmployee::getEmployeeId, employeeIds);
            }});
            List<Long> collect = hrmSalaryPlanEmployeeList.stream().map(a -> a.getEmployeeId().longValue()).collect(Collectors.toList());
            List<Integer> collect3 = employeeIds.stream().filter(a -> !collect.contains(a)).collect(Collectors.toList());

            List<HrmSalaryFixed> hrmSalaryFixeds = hrmSalaryFixedMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixed>() {{
//            (disHrmSalaryFixed::getEmployeeId);
                in(HrmSalaryFixed::getEmployeeId, employeeDOS.stream().map(e -> e.getId()).collect(Collectors.toList()));
                groupBy(HrmSalaryFixed::getEmployeeId);
            }});

            List<HrmSalaryFixed> hrmSalaryFixedList = hrmSalaryFixedMapper.selectList(new LambdaQueryWrapper<HrmSalaryFixed>() {{
                in(HrmSalaryFixed::getEmployeeId, employeeDOS.stream().map(e -> e.getId()).collect(Collectors.toList()));
            }});
            List<Long> collect1 = hrmSalaryFixedList.stream().map(hrmSalaryFixed -> hrmSalaryFixed.getEmployeeId().longValue()).collect(Collectors.toList());

            List<Long> employeeNotDingUserIdList = employeeDOS.stream().filter(d -> ObjectUtils.isEmpty(d.getDingUserId())).map(EmployeeDO::getId).collect(Collectors.toList());
            List<Integer> dingUserId = employeeDOS.stream().filter(d -> !ObjectUtils.isEmpty(d)).map(EmployeeDO::getDingUserId).collect(Collectors.toList());
            List<DingUser> dingUsers = dingUserMapper.selectList(new LambdaQueryWrapper<DingUser>() {{
                in(DingUser::getId, dingUserId);
            }});
            List<DingUser> dingUserStream = dingUsers.stream().filter(d -> ObjectUtils.isEmpty(d.getTeamId())).collect(Collectors.toList());
            //不在薪资组人员
            param.put("notSalaryPlan", employeeIds.size() - l);
            param.put("notSalaryPlanEmployeeIds", collect3);
            List<Long> collect2 = employeeDOS.stream().filter(a -> !collect1.contains(a.getId())).map(a -> a.getUserId()).collect(Collectors.toList());
            //未定薪人员
            param.put("notSalaryFixed", employeeIds.size() - hrmSalaryFixeds.size());
            param.put("notSalaryFixedEmployeeId", collect2);
            //未绑定钉钉薪资组人员
            param.put("notDingUserNum", employeeNotDingUserIdList.size());
            param.put("notDingUserId", employeeNotDingUserIdList);
            //没有考勤组人员
            param.put("notAttendanceTeam", dingUserStream.size());
            //核算薪资月考勤有异常人员
            param.put("notKqSystem",employeeIds.size()-l1);
            return param;
        }



    }


    @Override
    public Integer selectByAttendanceErrorEmployeeCount(String startTime, String endTime) {
        List<DingColumn> dingColumns = dingColumnMapper.selectList(new LambdaQueryWrapper<DingColumn>() {{
            eq(DingColumn::getAlias, "plan_detail");
        }});
        List<Integer> collect = dingColumns.stream().map(DingColumn::getId).collect(Collectors.toList());
        List<DingColumnValue> dingColumnValues = dingColumnValueMapper.selectList(new LambdaQueryWrapper<DingColumnValue>() {{
            in(DingColumnValue::getColumnId, collect);
            le(DingColumnValue::getDate, endTime);
            ge(DingColumnValue::getDate, startTime);
        }});

        if (ObjectUtils.isEmpty(dingColumnValues)) {
            return 0;
        }
        List<Integer> collect1 = dingColumnValues.stream().map(dingColumnValue -> dingColumnValue.getId()).collect(Collectors.toList());
        List<EmployeeDO> employeeDOS = employeeMapper.selectList(new LambdaQueryWrapper<EmployeeDO>() {{
            in(EmployeeDO::getDingUserId, collect1);
        }});
        if (ObjectUtils.isEmpty(employeeDOS)) {
            return 0;
        }
        return employeeDOS.size();
    }

    @Override
    public List<JSONObject> selectYcDingSelect() {
        List<JSONObject> resultList = new ArrayList<>();
        JSONObject result = new JSONObject();
        result.put("name", "旷工");
        resultList.add(result);
        result.put("name", "迟到");
        resultList.add(result);
        result.put("name", "早退");
        resultList.add(result);
        result.put("name", "请假");
        resultList.add(result);
        result.put("name", "正常");
        resultList.add(result);
        return Collections.emptyList();
    }

    @Override
    public List<JSONObject> selectByAttendanceErrorEmployee(String startTime, String endTime) {
        List<JSONObject> resultList = new ArrayList<>();
        List<DingColumn> dingColumns = dingColumnMapper.selectList(new LambdaQueryWrapper<DingColumn>() {{
            eq(DingColumn::getAlias, "plan_detail");
        }});
        List<Integer> collect = dingColumns.stream().map(DingColumn::getId).collect(Collectors.toList());
        List<DingColumnValue> dingColumnValues = dingColumnValueMapper.selectList(new LambdaQueryWrapper<DingColumnValue>() {{
            in(DingColumnValue::getColumnId, collect);
            le(DingColumnValue::getDate, endTime);
            ge(DingColumnValue::getDate, startTime);
        }});
        if (ObjectUtils.isEmpty(dingColumnValues)) {
            return new ArrayList<>();
        }
        List<Integer> collect1 = dingColumnValues.stream().map(dingColumnValue -> dingColumnValue.getId()).collect(Collectors.toList());
        List<EmployeeDO> employeeDOS = employeeMapper.selectList(new LambdaQueryWrapper<EmployeeDO>() {{
            in(EmployeeDO::getDingUserId, collect1);
        }});
        if (ObjectUtils.isEmpty(employeeDOS)) {
            return new ArrayList<>();
        }
        employeeDOS.forEach(employeeDO -> {
            CommonResult<PostLevelRespDTO> postLevelById = postLevelApi.getPostLevelById(employeeDO.getPostLevelId());
            CommonResult<List<DictDataRespDTO>> hrmEmployeeStatus = dictDataApi.getDictDataList("hrm_employee_status");
            CommonResult<List<DictDataRespDTO>> hrmEmploymentForm = dictDataApi.getDictDataList("hrm_employment_form");
            List<DictDataRespDTO> dictDataRespDTOS = hrmEmployeeStatus.getData();
            List<String> collectStatus = dictDataRespDTOS.stream().filter(d -> d.getValue().equals(employeeDO.getState() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
            List<DictDataRespDTO> dictForm = hrmEmploymentForm.getCheckedData();
            List<String> collectForm = dictForm.stream().filter(d -> d.getValue().equals(employeeDO.getEmploymentForm() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
            JSONObject result = new JSONObject();
            result.put("employeeName", employeeDO.getName());
            result.put("employeeNo", employeeDO.getEmployeeNo());
            result.put("postName", postLevelById.getCheckedData().getName());
            result.put("departmentName", deptApi.getDept(employeeDO.getDeptId()).getCheckedData().getName());
            if (!ObjectUtils.isEmpty(collectStatus)) {
                result.put("employeeStatus", collectStatus.get(0));
            } else {
                result.put("employeeStatus", "");
            }
            Long count = dingColumnValueMapper.selectCount(new LambdaQueryWrapper<DingColumnValue>() {{
                eq(DingColumnValue::getColumnId, collect);
                le(DingColumnValue::getDate, endTime);
                ge(DingColumnValue::getDate, startTime);
                eq(DingColumnValue::getDingUserId, employeeDO.getDingUserId());
            }});
            result.put("count", count);

            resultList.add(result);


        });
        return resultList;
    }

    @Override
    public List<JSONObject> selectByAttendanceErrorEmployeeInfo(String startTime, String endTime, Integer employeeId) {
        List<JSONObject> resultList = new ArrayList<>();
        List<DingColumn> dingColumns = dingColumnMapper.selectList(new LambdaQueryWrapper<DingColumn>() {{
            eq(DingColumn::getAlias, "attend_result");
        }});
        List<Integer> collect = dingColumns.stream().map(DingColumn::getId).collect(Collectors.toList());
        EmployeeDO employeeDO = employeeMapper.selectById(employeeId);
        CommonResult<PostLevelRespDTO> postLevelById = postLevelApi.getPostLevelById(employeeDO.getPostLevelId());
        CommonResult<List<DictDataRespDTO>> hrmEmployeeStatus = dictDataApi.getDictDataList("hrm_employee_status");
        CommonResult<List<DictDataRespDTO>> hrmEmploymentForm = dictDataApi.getDictDataList("hrm_employment_form");
        List<DictDataRespDTO> dictDataRespDTOS = hrmEmployeeStatus.getData();
        List<String> collectStatus = dictDataRespDTOS.stream().filter(d -> d.getValue().equals(employeeDO.getState() + "")).map(di -> di.getLabel()).collect(Collectors.toList());
        List<DictDataRespDTO> dictForm = hrmEmploymentForm.getCheckedData();
        List<String> collectForm = dictForm.stream().filter(d -> d.getValue().equals(employeeDO.getEmploymentForm() + "")).map(di -> di.getLabel()).collect(Collectors.toList());

        List<DingColumnValue> dingColumnValues = dingColumnValueMapper.selectList(new LambdaQueryWrapper<DingColumnValue>() {{
            eq(DingColumnValue::getColumnId, collect);
            le(DingColumnValue::getDate, endTime);
            ge(DingColumnValue::getDate, startTime);
            eq(DingColumnValue::getDingUserId, employeeDO.getDingUserId());

        }});
        dingColumnValues.forEach(dingColumnValue -> {
            JSONObject result = new JSONObject();
            result.put("date", dingColumnValue.getDate());
            result.put("employeeName", employeeDO.getName());
            result.put("employeeNo", employeeDO.getEmployeeNo());
            result.put("postName", postLevelById.getCheckedData().getName());
            result.put("departmentName", deptApi.getDept(employeeDO.getDeptId()).getCheckedData().getName());
            if (!ObjectUtils.isEmpty(collectStatus)) {
                result.put("employeeStatus", collectStatus.get(0));
            } else {
                result.put("employeeStatus", "");
            }
            resultList.add(result);
        });
        return resultList;
    }

    @Override
    public Integer handlingDingExceptions(JSONObject jsonObject) {
        Integer employeeId = jsonObject.getInteger("employeeId");
        List<JSONObject> dingErrorColumn = jsonObject.getList("dingErrorColumn", JSONObject.class);
        return 0;
    }

    public static void main(String[] args) {
        LocalDate date = LocalDate.parse("2025-02" + "-15", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        // 获取该月的开始日
        Long startOfMonth = date.with(TemporalAdjusters.firstDayOfMonth()).atStartOfDay().atZone(ZoneOffset.UTC).toInstant().toEpochMilli();
        // 获取该月的结束日
        Long endOfMonth = date.with(TemporalAdjusters.lastDayOfMonth()).atStartOfDay().atZone(ZoneOffset.UTC).toInstant().toEpochMilli();
    }

}
